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

Function TestNetErrors

pkg/errors/errors_test.go:112–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestNetErrors(t *testing.T) {
113 t.Parallel()
114 a := assertions.New(t)
115
116 errDummy := fmt.Errorf("dummy")
117
118 for _, tc := range []struct {
119 Name string
120 Error error
121 Validate func(err error, e *errors.Error, a *assertions.Assertion)
122 }{
123 {
124 Name: "DNSError",
125 Error: &net.DNSError{
126 Err: "SERVFAIL",
127 Name: "invalid-name",
128 IsNotFound: true,
129 IsTemporary: false,
130 IsTimeout: false,
131 Server: "dns-server",
132 },
133 Validate: func(err error, e *errors.Error, a *assertions.Assertion) {
134 a.So(e.FullName(), should.Equal, "pkg/errors:net_dns")
135 a.So(errors.IsUnavailable(e), should.BeTrue)
136 a.So(e.PublicAttributes(), should.Resemble, map[string]any{
137 "message": err.Error(),
138 "timeout": false,
139 "not_found": true,
140 })
141 },
142 },
143 {
144 Name: "UnknownNetworkError",
145 Error: net.UnknownNetworkError("1.1.1.1"),
146 Validate: func(err error, e *errors.Error, a *assertions.Assertion) {
147 a.So(e.FullName(), should.Equal, "pkg/errors:net_unknown_network")
148 a.So(errors.IsNotFound(e), should.BeTrue)
149 a.So(e.PublicAttributes(), should.Resemble, map[string]any{
150 "message": err.Error(),
151 "timeout": false,
152 })
153 },
154 },
155 {
156 Name: "InvalidAddrError",
157 Error: net.InvalidAddrError("1.1.1.1"),
158 Validate: func(err error, e *errors.Error, a *assertions.Assertion) {
159 a.So(e.FullName(), should.Equal, "pkg/errors:net_invalid_addr")
160 a.So(errors.IsInvalidArgument(e), should.BeTrue)
161 a.So(e.PublicAttributes(), should.Resemble, map[string]any{
162 "message": err.Error(),
163 "timeout": false,
164 })
165 },
166 },
167 {
168 Name: "AddrError",
169 Error: &net.AddrError{

Callers

nothing calls this directly

Calls 12

IsUnavailableFunction · 0.92
IsNotFoundFunction · 0.92
IsInvalidArgumentFunction · 0.92
FromFunction · 0.92
NewMethod · 0.65
ErrorfMethod · 0.65
FullNameMethod · 0.65
PublicAttributesMethod · 0.65
ErrorMethod · 0.65
CauseMethod · 0.65
RunMethod · 0.65
ValidateMethod · 0.65

Tested by

no test coverage detected