MCPcopy Index your code
hub / github.com/cli/cli / TestCategorizeHost

Function TestCategorizeHost

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

Source from the content-addressed store, hash-verified

159}
160
161func TestCategorizeHost(t *testing.T) {
162 tests := []struct {
163 name string
164 host string
165 want string
166 }{
167 {
168 name: "github.com returns github.com",
169 host: "github.com",
170 want: "github.com",
171 },
172 {
173 name: "classic GHES hostname returns ghes",
174 host: "ghe.io",
175 want: "ghes",
176 },
177 {
178 name: "arbitrary enterprise hostname returns ghes",
179 host: "enterprise.example.com",
180 want: "ghes",
181 },
182 {
183 name: "tenant subdomain of ghe.com returns tenancy",
184 host: "tenant.ghe.com",
185 want: "tenancy",
186 },
187 {
188 name: "api subdomain under tenant returns tenancy",
189 host: "api.tenant.ghe.com",
190 want: "tenancy",
191 },
192 {
193 name: "bare ghe.com returns ghes",
194 host: "ghe.com",
195 want: "ghes",
196 },
197 {
198 name: "github.localhost returns uncategorized",
199 host: "github.localhost",
200 want: "uncategorized",
201 },
202 {
203 name: "github.com subdomain returns uncategorized",
204 host: "garage.github.com",
205 want: "uncategorized",
206 },
207 }
208 for _, tt := range tests {
209 t.Run(tt.name, func(t *testing.T) {
210 assert.Equal(t, tt.want, CategorizeHost(tt.host))
211 })
212 }
213}

Callers

nothing calls this directly

Calls 3

CategorizeHostFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected