(t *testing.T)
| 184 | } |
| 185 | |
| 186 | func TestCategorizeHost(t *testing.T) { |
| 187 | tests := []struct { |
| 188 | name string |
| 189 | host string |
| 190 | want string |
| 191 | }{ |
| 192 | { |
| 193 | name: "github.com returns github.com", |
| 194 | host: "github.com", |
| 195 | want: "github.com", |
| 196 | }, |
| 197 | { |
| 198 | name: "classic GHES hostname returns ghes", |
| 199 | host: "ghe.io", |
| 200 | want: "ghes", |
| 201 | }, |
| 202 | { |
| 203 | name: "arbitrary enterprise hostname returns ghes", |
| 204 | host: "enterprise.example.com", |
| 205 | want: "ghes", |
| 206 | }, |
| 207 | { |
| 208 | name: "tenant subdomain of ghe.com returns tenancy", |
| 209 | host: "tenant.ghe.com", |
| 210 | want: "tenancy", |
| 211 | }, |
| 212 | { |
| 213 | name: "api subdomain under tenant returns tenancy", |
| 214 | host: "api.tenant.ghe.com", |
| 215 | want: "tenancy", |
| 216 | }, |
| 217 | { |
| 218 | name: "bare ghe.com returns ghes", |
| 219 | host: "ghe.com", |
| 220 | want: "ghes", |
| 221 | }, |
| 222 | { |
| 223 | name: "github.localhost returns uncategorized", |
| 224 | host: "github.localhost", |
| 225 | want: "uncategorized", |
| 226 | }, |
| 227 | { |
| 228 | name: "github.com subdomain returns uncategorized", |
| 229 | host: "garage.github.com", |
| 230 | want: "uncategorized", |
| 231 | }, |
| 232 | } |
| 233 | for _, tt := range tests { |
| 234 | t.Run(tt.name, func(t *testing.T) { |
| 235 | assert.Equal(t, tt.want, CategorizeHost(tt.host)) |
| 236 | }) |
| 237 | } |
| 238 | } |
nothing calls this directly
no test coverage detected