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

Function TestOpenFails

writer_test.go:162–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

160}
161
162func TestOpenFails(t *testing.T) {
163 tests := []struct {
164 paths []string
165 }{
166 {paths: []string{"./non-existent-dir/file"}}, // directory doesn't exist
167 {paths: []string{"stdout", "./non-existent-dir/file"}}, // directory doesn't exist
168 {paths: []string{"://foo.log"}}, // invalid URL, scheme can't begin with colon
169 {paths: []string{"mem://somewhere"}}, // scheme not registered
170 }
171
172 for _, tt := range tests {
173 _, cleanup, err := Open(tt.paths...)
174 require.Nil(t, cleanup, "Cleanup function should be nil")
175 assert.Error(t, err, "Open with invalid URL should fail.")
176 }
177}
178
179func TestOpenOtherErrors(t *testing.T) {
180 tempName := filepath.Join(t.TempDir(), "test.log")

Callers

nothing calls this directly

Calls 2

OpenFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected