(t *testing.T)
| 213 | } |
| 214 | |
| 215 | func TestDetectTenant_CloudPath(t *testing.T) { |
| 216 | srv := fakeCloud(t, func(w http.ResponseWriter, _ *http.Request) { |
| 217 | w.Header().Set("Content-Type", "application/json") |
| 218 | _ = json.NewEncoder(w).Encode(map[string]any{"items": []map[string]any{ |
| 219 | {"tenant_id": "11111111-1111-1111-1111-111111111111", "status": "active", "team_name": "team-x", "host": "acme.us.platform.cloudquery.io", "subdomain": "acme"}, |
| 220 | }}) |
| 221 | }, nil) |
| 222 | t.Setenv(envAPIURL, srv.URL) |
| 223 | |
| 224 | url, ok := DetectTenant(context.Background(), "tok", "team-x") |
| 225 | require.True(t, ok) |
| 226 | require.Equal(t, "https://acme.us.platform.cloudquery.io", url, "url is built from the active tenant's host") |
| 227 | } |
| 228 | |
| 229 | // DetectTenant must make the SAME multi-tenant decision auto-injection does: |
| 230 | // skip (report nothing) when a team has several active tenants and no |
nothing calls this directly
no test coverage detected