diff --git a/Makefile b/Makefile index b0222544..69cd761e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PACKAGES=`go list ./... | grep -v example` test: - go test --count 1 -v -cover ${PACKAGES} + go test -race --count 1 -v -cover ${PACKAGES} format: go fmt github.com/xitongsys/parquet-go/... diff --git a/writer/writer_test.go b/writer/writer_test.go index cee981e3..d390596c 100644 --- a/writer/writer_test.go +++ b/writer/writer_test.go @@ -237,3 +237,16 @@ func TestNewWriterWithInvaidFile(t *testing.T) { assert.Nil(t, pw) assert.ErrorIs(t, err, testWriteErr) } + +func TestWriteStopRaceConditionOnError(t *testing.T) { + var buf bytes.Buffer + fw := writerfile.NewWriterFile(&buf) + pw, err := NewJSONWriter(`{"Tag":"name=parquet-go-root","Fields":[{"Tag":"name=x, type=INT64"}]}`, fw, 4) + assert.NoError(t, err) + + for i := 0; i < 1000; i++ { + entry := fmt.Sprintf(`{"not-x":%d}`, i) + assert.NoError(t, pw.Write(entry)) + } + assert.Error(t, pw.WriteStop()) +}