This commit is contained in:
maksim bondarenko
2026-03-23 16:57:33 +02:00
parent 9a0a53354e
commit 91c062b174
@@ -97,3 +97,31 @@ func TestErrorsAsExtractionMatrix(t *testing.T) {
}) })
} }
} }
func TestErrorMethodOutput(t *testing.T) {
tests := []struct {
name string
err *MyError
expectedMsg string
}{
{
name: "nil receiver",
err: nil,
expectedMsg: "<nil MyError>",
},
{
name: "normal error",
err: &MyError{Op: "test-operation"},
expectedMsg: "operation failed: test-operation",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
msg := tt.err.Error()
if msg != tt.expectedMsg {
t.Errorf("expected message: %q, got: %q", tt.expectedMsg, msg)
}
})
}
}