MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestUpdateOrgSetsDefaultWorkerProfile

Function TestUpdateOrgSetsDefaultWorkerProfile

controlplane/admin/api_test.go:1693–1721  ·  view source on GitHub ↗

--- Org default worker profile (default_worker_cpu/memory/ttl) ---

(t *testing.T)

Source from the content-addressed store, hash-verified

1691 req := httptest.NewRequest(http.MethodDelete, "/api/v1/orgs/analytics", nil)
1692 rec := httptest.NewRecorder()
1693 router.ServeHTTP(rec, req)
1694
1695 if rec.Code != http.StatusConflict {
1696 t.Fatalf("status = %d, want %d: %s", rec.Code, http.StatusConflict, rec.Body.String())
1697 }
1698 if !strings.Contains(rec.Body.String(), "deprovision") {
1699 t.Fatalf("expected error to mention deprovision, got: %s", rec.Body.String())
1700 }
1701 if _, ok := store.orgs["analytics"]; !ok {
1702 t.Fatal("expected org to survive a rejected delete")
1703 }
1704 if _, ok := store.warehouses["analytics"]; !ok {
1705 t.Fatal("expected warehouse to survive a rejected delete")
1706 }
1707}
1708
1709func TestDeleteOrgSucceedsAfterWarehouseRemoved(t *testing.T) {
1710 store := newFakeAPIStore()
1711 seedOrgWithWarehouse(store, "analytics")
1712 delete(store.warehouses, "analytics")
1713 router := newTestAPIRouter(store)
1714
1715 req := httptest.NewRequest(http.MethodDelete, "/api/v1/orgs/analytics", nil)
1716 rec := httptest.NewRecorder()
1717 router.ServeHTTP(rec, req)
1718
1719 if rec.Code != http.StatusOK {
1720 t.Fatalf("status = %d, want %d: %s", rec.Code, http.StatusOK, rec.Body.String())
1721 }
1722 if _, ok := store.orgs["analytics"]; ok {
1723 t.Fatal("expected org to be deleted once the warehouse is gone")
1724 }

Callers

nothing calls this directly

Calls 3

newFakeAPIStoreFunction · 0.85
newTestAPIRouterFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected