MCPcopy
hub / github.com/uber-go/zap / TestAddSyncWriteSyncer

Function TestAddSyncWriteSyncer

zapcore/write_syncer_test.go:45–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestAddSyncWriteSyncer(t *testing.T) {
46 buf := &bytes.Buffer{}
47 concrete := &writeSyncSpy{Writer: buf}
48 ws := AddSync(concrete)
49 requireWriteWorks(t, ws)
50
51 require.NoError(t, ws.Sync(), "Unexpected error syncing a WriteSyncer.")
52 require.True(t, concrete.Called(), "Expected to dispatch to concrete type's Sync method.")
53
54 concrete.SetError(errors.New("fail"))
55 assert.Error(t, ws.Sync(), "Expected to propagate errors from concrete type's Sync method.")
56}
57
58func TestAddSyncWriter(t *testing.T) {
59 // If we pass a plain io.Writer, make sure that we still get a WriteSyncer

Callers

nothing calls this directly

Calls 6

AddSyncFunction · 0.85
requireWriteWorksFunction · 0.85
CalledMethod · 0.80
SetErrorMethod · 0.80
SyncMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected