(t *testing.T)
| 110 | } |
| 111 | |
| 112 | func 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{ |
nothing calls this directly
no test coverage detected