(t *testing.T)
| 247 | } |
| 248 | |
| 249 | func TestDefaultKeyRewriter(t *testing.T) { |
| 250 | for _, tc := range []struct { |
| 251 | desc string |
| 252 | serverURL string |
| 253 | expected string |
| 254 | }{ |
| 255 | { |
| 256 | desc: "valid URL with IP and without port", |
| 257 | serverURL: "http://127.0.0.1/something", |
| 258 | expected: "127.0.0.1/something", |
| 259 | }, |
| 260 | { |
| 261 | desc: "URL with IP and Port", |
| 262 | serverURL: "http://192.162.233.123:8313/key/another", |
| 263 | expected: "192.162.233.123-port-8313/key/another", |
| 264 | }, |
| 265 | { |
| 266 | desc: "URL with hostname", |
| 267 | serverURL: "https://docker.com/credential/key", |
| 268 | expected: "docker.com/credential/key", |
| 269 | }, |
| 270 | { |
| 271 | desc: "trailing forward-slash", |
| 272 | serverURL: "https://example.com/credential/key/", |
| 273 | expected: "example.com/credential/key", |
| 274 | }, |
| 275 | } { |
| 276 | t.Run(tc.desc, func(t *testing.T) { |
| 277 | assert.Equal(t, tc.expected, DefaultKeyRewriter(tc.serverURL)) |
| 278 | }) |
| 279 | } |
| 280 | } |
nothing calls this directly
no test coverage detected