(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestTenantName(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | host string |
| 12 | wantTenant string |
| 13 | wantFound bool |
| 14 | }{ |
| 15 | { |
| 16 | host: "github.com", |
| 17 | wantTenant: "github.com", |
| 18 | }, |
| 19 | { |
| 20 | host: "github.localhost", |
| 21 | wantTenant: "github.localhost", |
| 22 | }, |
| 23 | { |
| 24 | host: "garage.github.com", |
| 25 | wantTenant: "github.com", |
| 26 | }, |
| 27 | { |
| 28 | host: "ghe.com", |
| 29 | wantTenant: "ghe.com", |
| 30 | }, |
| 31 | { |
| 32 | host: "tenant.ghe.com", |
| 33 | wantTenant: "tenant", |
| 34 | wantFound: true, |
| 35 | }, |
| 36 | { |
| 37 | host: "api.tenant.ghe.com", |
| 38 | wantTenant: "tenant", |
| 39 | wantFound: true, |
| 40 | }, |
| 41 | } |
| 42 | for _, tt := range tests { |
| 43 | t.Run(tt.host, func(t *testing.T) { |
| 44 | if tenant, found := TenantName(tt.host); tenant != tt.wantTenant || found != tt.wantFound { |
| 45 | t.Errorf("TenantName(%v) = %v %v, want %v %v", tt.host, tenant, found, tt.wantTenant, tt.wantFound) |
| 46 | } |
| 47 | }) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func TestHostnameValidator(t *testing.T) { |
| 52 | tests := []struct { |
nothing calls this directly
no test coverage detected