MCPcopy Create free account
hub / github.com/containers/image / TestSplitHostname

Function TestSplitHostname

docker/reference/reference_test.go:282–337  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func TestSplitHostname(t *testing.T) {
283 testcases := []struct {
284 input string
285 domain string
286 name string
287 }{
288 {
289 input: "test.com/foo",
290 domain: "test.com",
291 name: "foo",
292 },
293 {
294 input: "test_com/foo",
295 domain: "",
296 name: "test_com/foo",
297 },
298 {
299 input: "test:8080/foo",
300 domain: "test:8080",
301 name: "foo",
302 },
303 {
304 input: "test.com:8080/foo",
305 domain: "test.com:8080",
306 name: "foo",
307 },
308 {
309 input: "test-com:8080/foo",
310 domain: "test-com:8080",
311 name: "foo",
312 },
313 {
314 input: "xn--n3h.com:18080/foo",
315 domain: "xn--n3h.com:18080",
316 name: "foo",
317 },
318 }
319 for _, testcase := range testcases {
320 failf := func(format string, v ...interface{}) {
321 t.Logf(strconv.Quote(testcase.input)+": "+format, v...)
322 t.Fail()
323 }
324
325 named, err := WithName(testcase.input)
326 if err != nil {
327 failf("error parsing name: %s", err)
328 }
329 domain, name := SplitHostname(named)
330 if domain != testcase.domain {
331 failf("unexpected domain: got %q, expected %q", domain, testcase.domain)
332 }
333 if name != testcase.name {
334 failf("unexpected name: got %q, expected %q", name, testcase.name)
335 }
336 }
337}
338
339type serializationType struct {

Callers

nothing calls this directly

Calls 2

WithNameFunction · 0.85
SplitHostnameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…