Skip to content

Commit 27ff715

Browse files
authored
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
1 parent 26abe3e commit 27ff715

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

.gitattributes

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

.github/workflows/go.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Go
2-
on: [push]
2+
on: [push, pull_request]
33

44

55
jobs:
@@ -27,7 +27,8 @@ jobs:
2727
- name: Build
2828
run: go build -v .
2929

30-
30+
- name: Test
31+
run: go test -v ./cli/output/...
3132

3233
#
3334
#

cli/output/xmlw/xmlw_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ func TestRecordWriter_TblTypes(t *testing.T) {
103103

104104
want, err := ioutil.ReadFile("testdata/tbl_types.xml")
105105
require.NoError(t, err)
106-
require.Equal(t, want, buf.Bytes())
106+
require.Equal(t, string(want), buf.String())
107107
}

testh/testh.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,22 @@ func (h *Helper) Source(handle string) *source.Source {
155155

156156
srcFile, err := os.Open(fpath)
157157
require.NoError(t, err)
158-
defer func() { assert.NoError(t, srcFile.Close()) }()
158+
defer func() {assert.NoError(t, srcFile.Close())}()
159159

160160
destFile, err := ioutil.TempFile("", "*_"+filepath.Base(src.Location))
161161
require.NoError(t, err)
162-
defer func() { assert.NoError(t, destFile.Close()) }()
163-
t.Cleanup(func() {
164-
assert.NoError(t, os.Remove(destFile.Name()))
162+
defer func() {assert.NoError(t, destFile.Close())}()
163+
164+
destFileName := destFile.Name()
165+
166+
h.Cleanup.AddE(func() error {
167+
return os.Remove(destFileName)
165168
})
166169

167170
_, err = io.Copy(destFile, srcFile)
168171
require.NoError(t, err)
169172

170-
src.Location = sqlite3.Prefix + destFile.Name()
173+
src.Location = sqlite3.Prefix + destFileName
171174
}
172175
h.srcCache[handle] = src
173176
return src

0 commit comments

Comments
 (0)