package runtime import "testing" func TestSanitizeImage(t *testing.T) { got := sanitizeImage("mcr.example:8443/mcdoc:v0.1.0") if got != "mcr.example_8443_mcdoc_v0.1.0" { t.Errorf("sanitizeImage = %q", got) } } func TestBinaryName(t *testing.T) { cases := map[string]string{ "host:8443/mcdoc:v0.1.0": "mcdoc", "mcdoc:v1": "mcdoc", "reg/uktest": "uktest", } for in, want := range cases { if got := binaryName(in); got != want { t.Errorf("binaryName(%q) = %q, want %q", in, got, want) } } } func TestHostForward(t *testing.T) { cases := map[string]string{ "100.88.197.9:18080:8080": "tcp:100.88.197.9:18080-:8080", "18080:8080": "tcp:127.0.0.1:18080-:8080", "8080": "tcp:127.0.0.1:8080-:8080", } for in, want := range cases { if got := hostForward(in); got != want { t.Errorf("hostForward(%q) = %q, want %q", in, got, want) } } } func TestGuestPorts(t *testing.T) { got := guestPorts([]string{"100.88.197.9:18080:8080", "9090"}) if len(got) != 2 || got[0] != "8080" || got[1] != "9090" { t.Errorf("guestPorts = %v", got) } }