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

Function TestProvisionAutoCreatesOrg

controlplane/provisioning/api_test.go:214–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

212// for a missing row, refusal on the last team (an org must always have at
213// least one).
214func (s *fakeStore) DeleteOrgTeam(orgID string, teamID int64) error {
215 if _, ok := s.teams[orgID][teamID]; !ok {
216 return configstore.ErrOrgTeamNotFound
217 }
218 if len(s.teams[orgID]) == 1 {
219 return configstore.ErrLastOrgTeam
220 }
221 delete(s.teams[orgID], teamID)
222 return nil
223}
224
225func (s *fakeStore) Provision(req ProvisionRequest) error {
226 reqCopy := req
227 s.lastProvision = &reqCopy
228 // Pre-check: warehouse already exists in non-terminal state? Mirrors
229 // createPendingWarehouseTx so the handler's 409 branch is exercised.
230 if existing, ok := s.warehouses[req.OrgID]; ok &&
231 existing.State != configstore.ManagedWarehouseStateFailed &&
232 existing.State != configstore.ManagedWarehouseStateDeleted {
233 return ErrWarehouseNonTerminal
234 }
235
236 // Stage the writes into shadow maps so a mid-step failure can roll

Callers

nothing calls this directly

Calls 3

newTestRouterFunction · 0.85
newFakeStoreFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected