MCPcopy Create free account
hub / github.com/docker/cli / TestParseHostname

Function TestParseHostname

cli/command/container/opts_test.go:393–414  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

391}
392
393func TestParseHostname(t *testing.T) {
394 validHostnames := map[string]string{
395 "hostname": "hostname",
396 "host-name": "host-name",
397 "hostname123": "hostname123",
398 "123hostname": "123hostname",
399 "hostname-of-63-bytes-long-should-be-valid-and-without-any-error": "hostname-of-63-bytes-long-should-be-valid-and-without-any-error",
400 }
401 hostnameWithDomain := "--hostname=hostname.domainname"
402 hostnameWithDomainTld := "--hostname=hostname.domainname.tld"
403 for hostname, expectedHostname := range validHostnames {
404 if config, _, _ := mustParse(t, "--hostname="+hostname); config.Hostname != expectedHostname {
405 t.Fatalf("Expected the config to have 'hostname' as %q, got %q", expectedHostname, config.Hostname)
406 }
407 }
408 if config, _, _ := mustParse(t, hostnameWithDomain); config.Hostname != "hostname.domainname" || config.Domainname != "" {
409 t.Fatalf("Expected the config to have 'hostname' as hostname.domainname, got %q", config.Hostname)
410 }
411 if config, _, _ := mustParse(t, hostnameWithDomainTld); config.Hostname != "hostname.domainname.tld" || config.Domainname != "" {
412 t.Fatalf("Expected the config to have 'hostname' as hostname.domainname.tld, got %q", config.Hostname)
413 }
414}
415
416func TestParseHostnameDomainname(t *testing.T) {
417 validDomainnames := map[string]string{

Callers

nothing calls this directly

Calls 1

mustParseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…