(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestAttributesError(t *testing.T) { |
| 26 | t.Parallel() |
| 27 | a := assertions.New(t) |
| 28 | |
| 29 | errInvalidFoo := errors.DefineInvalidArgument("test_attributes_invalid_foo", "Invalid Foo: {foo}", "foo") |
| 30 | |
| 31 | a.So(errInvalidFoo.Attributes(), should.BeEmpty) |
| 32 | |
| 33 | a.So(func() { errInvalidFoo.WithAttributes("only_key") }, should.Panic) //nolint:errcheck |
| 34 | |
| 35 | err1 := errInvalidFoo.WithAttributes("foo", "bar") |
| 36 | err2 := err1.WithAttributes("bar", "baz") |
| 37 | |
| 38 | a.So(err1, should.HaveSameErrorDefinitionAs, errInvalidFoo) |
| 39 | a.So(errors.Attributes(err1), should.Resemble, map[string]any{"foo": "bar"}) |
| 40 | a.So(errors.PublicAttributes(err1), should.Resemble, map[string]any{"foo": "bar"}) |
| 41 | |
| 42 | a.So(err2, should.HaveSameErrorDefinitionAs, err1) |
| 43 | a.So(err2, should.HaveSameErrorDefinitionAs, errInvalidFoo) |
| 44 | a.So(errors.Attributes(err2), should.Resemble, map[string]any{"foo": "bar", "bar": "baz"}) |
| 45 | a.So(errors.PublicAttributes(err2), should.Resemble, map[string]any{"foo": "bar"}) |
| 46 | } |
| 47 | |
| 48 | func TestAttributes(t *testing.T) { |
| 49 | t.Parallel() |
nothing calls this directly
no test coverage detected