MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestMessageFormat

Function TestMessageFormat

pkg/errors/definitions_test.go:33–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestMessageFormat(t *testing.T) {
34 t.Parallel()
35 a := assertions.New(t)
36
37 args := errors.MessageFormatArguments(
38 "Application with ID {app_id} could not be found in namespace { ns } or namespace { ns } does not exist",
39 )
40 a.So(args, should.HaveLength, 2) // no duplicates
41 a.So(args, should.Contain, "app_id")
42 a.So(args, should.Contain, "ns")
43
44 err := errors.Define("test_message_format", "MessageFormat {foo}, {bar}")
45 instance := err.WithAttributes("foo", "my-foo", "bar", "my-bar")
46 a.So(instance.PublicAttributes(), should.ContainKey, "foo")
47 a.So(instance.PublicAttributes(), should.ContainKey, "bar")
48}

Callers

nothing calls this directly

Calls 4

DefineFunction · 0.92
NewMethod · 0.65
PublicAttributesMethod · 0.65
WithAttributesMethod · 0.45

Tested by

no test coverage detected