MCPcopy
hub / github.com/cli/cli / TestHostnameValidator

Function TestHostnameValidator

internal/ghinstance/host_test.go:51–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestHostnameValidator(t *testing.T) {
52 tests := []struct {
53 name string
54 input string
55 wantsErr bool
56 }{
57 {
58 name: "valid hostname",
59 input: "internal.instance",
60 wantsErr: false,
61 },
62 {
63 name: "hostname with slashes",
64 input: "//internal.instance",
65 wantsErr: true,
66 },
67 {
68 name: "empty hostname",
69 input: " ",
70 wantsErr: true,
71 },
72 {
73 name: "hostname with colon",
74 input: "internal.instance:2205",
75 wantsErr: true,
76 },
77 }
78
79 for _, tt := range tests {
80 t.Run(tt.name, func(t *testing.T) {
81 err := HostnameValidator(tt.input)
82 if tt.wantsErr {
83 assert.Error(t, err)
84 return
85 }
86 assert.NoError(t, err)
87 })
88 }
89}
90
91func TestGraphQLEndpoint(t *testing.T) {
92 tests := []struct {

Callers

nothing calls this directly

Calls 3

HostnameValidatorFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected