Added go test to github action; fixed Windows test issues (#52)

* initial test of testing workflow

* added .gitattributes for crlf issue on windows

* testh was attempting to remove the copied sqlite3 file before it was closed by sqlite3.database.Close()

* fiddling with .gitattributes to get line endings to work
This commit is contained in:
Neil O'Toole 2020-08-07 23:10:41 -06:00 committed by GitHub
parent 26abe3eb6d
commit 27ff71516e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 8 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto eol=lf

View File

@ -1,5 +1,5 @@
name: Go name: Go
on: [push] on: [push, pull_request]
jobs: jobs:
@ -27,7 +27,8 @@ jobs:
- name: Build - name: Build
run: go build -v . run: go build -v .
- name: Test
run: go test -v ./cli/output/...
# #
# #

View File

@ -103,5 +103,5 @@ func TestRecordWriter_TblTypes(t *testing.T) {
want, err := ioutil.ReadFile("testdata/tbl_types.xml") want, err := ioutil.ReadFile("testdata/tbl_types.xml")
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, want, buf.Bytes()) require.Equal(t, string(want), buf.String())
} }

View File

@ -155,19 +155,22 @@ func (h *Helper) Source(handle string) *source.Source {
srcFile, err := os.Open(fpath) srcFile, err := os.Open(fpath)
require.NoError(t, err) require.NoError(t, err)
defer func() { assert.NoError(t, srcFile.Close()) }() defer func() {assert.NoError(t, srcFile.Close())}()
destFile, err := ioutil.TempFile("", "*_"+filepath.Base(src.Location)) destFile, err := ioutil.TempFile("", "*_"+filepath.Base(src.Location))
require.NoError(t, err) require.NoError(t, err)
defer func() { assert.NoError(t, destFile.Close()) }() defer func() {assert.NoError(t, destFile.Close())}()
t.Cleanup(func() {
assert.NoError(t, os.Remove(destFile.Name())) destFileName := destFile.Name()
h.Cleanup.AddE(func() error {
return os.Remove(destFileName)
}) })
_, err = io.Copy(destFile, srcFile) _, err = io.Copy(destFile, srcFile)
require.NoError(t, err) require.NoError(t, err)
src.Location = sqlite3.Prefix + destFile.Name() src.Location = sqlite3.Prefix + destFileName
} }
h.srcCache[handle] = src h.srcCache[handle] = src
return src return src