Skip to content

Commit

Permalink
zapcore: add called Stop twice testcase
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
  • Loading branch information
zchee committed Jun 16, 2021
1 parent 15b6b06 commit 3306b8c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions zapcore/buffered_write_syncer_test.go
Expand Up @@ -53,6 +53,14 @@ func TestBufferWriter(t *testing.T) {
assert.Equal(t, "foo", buf.String(), "Unexpected log string")
})

t.Run("stop twice", func(t *testing.T) {
ws := &BufferedWriteSyncer{WS: &ztest.FailWriter{}}
_, err := ws.Write([]byte("foo"))
require.NoError(t, err, "Unexpected error writing to WriteSyncer.")
assert.Error(t, ws.Stop(), "Expected stop to fail.")
assert.NoError(t, ws.Stop(), "Expected stop to not fail.")
})

t.Run("wrap twice", func(t *testing.T) {
buf := &bytes.Buffer{}
bufsync := &BufferedWriteSyncer{WS: AddSync(buf)}
Expand Down

0 comments on commit 3306b8c

Please sign in to comment.