(t *testing.T)
| 159 | } |
| 160 | |
| 161 | func 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 | } |
nothing calls this directly
no test coverage detected