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

Function TestErrorConstructors

error_test.go:34–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func TestErrorConstructors(t *testing.T) {
35 fail := errors.New("fail")
36
37 tests := []struct {
38 name string
39 field Field
40 expect Field
41 }{
42 {"Error", Skip(), Error(nil)},
43 {"Error", Field{Key: "error", Type: zapcore.ErrorType, Interface: fail}, Error(fail)},
44 {"NamedError", Skip(), NamedError("foo", nil)},
45 {"NamedError", Field{Key: "foo", Type: zapcore.ErrorType, Interface: fail}, NamedError("foo", fail)},
46 {"Any:Error", Any("k", errors.New("v")), NamedError("k", errors.New("v"))},
47 {"Any:Errors", Any("k", []error{errors.New("v")}), Errors("k", []error{errors.New("v")})},
48 }
49
50 for _, tt := range tests {
51 if !assert.Equal(t, tt.expect, tt.field, "Unexpected output from convenience field constructor %s.", tt.name) {
52 t.Logf("type expected: %T\nGot: %T", tt.expect.Interface, tt.field.Interface)
53 }
54 assertCanBeReused(t, tt.field)
55 }
56}
57
58func TestErrorArrayConstructor(t *testing.T) {
59 tests := []struct {

Callers

nothing calls this directly

Calls 7

SkipFunction · 0.85
ErrorFunction · 0.85
NamedErrorFunction · 0.85
AnyFunction · 0.85
ErrorsFunction · 0.85
assertCanBeReusedFunction · 0.70
LogfMethod · 0.65

Tested by

no test coverage detected