MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestCheckAgentCreate_BlocksAtCap

Function TestCheckAgentCreate_BlocksAtCap

internal/limits/limits_test.go:160–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

158}
159
160func TestCheckAgentCreate_BlocksAtCap(t *testing.T) {
161 store := &fakeStore{found: true, row: Limits{PlanCode: "free", MaxAgents: 3, MaxDomains: 1, MaxMessagesMonth: 1, MaxStorageBytes: 1, UpgradeURL: "https://up"}}
162 counter := &fakeCounter{agents: 3}
163 e := newEnforcerWithReader(store, counter, defaultsForTest(), 0)
164
165 err := e.CheckAgentCreate(context.Background(), "user1")
166 le, ok := IsLimitExceeded(err)
167 if !ok {
168 t.Fatalf("CheckAgentCreate at cap = %v, want LimitExceededError", err)
169 }
170 if le.Resource != "agents" {
171 t.Errorf("Resource = %q, want agents", le.Resource)
172 }
173 if le.Limit != 3 || le.Current != 3 {
174 t.Errorf("Limit/Current = %d/%d, want 3/3", le.Limit, le.Current)
175 }
176 if le.Limits.UpgradeURL != "https://up" {
177 t.Errorf("UpgradeURL not propagated to error: %q", le.Limits.UpgradeURL)
178 }
179}
180
181func TestCheckDomainCreate_BlocksAtCap(t *testing.T) {
182 store := &fakeStore{found: true, row: Limits{MaxAgents: 100, MaxDomains: 1, MaxMessagesMonth: 1, MaxStorageBytes: 1}}

Callers

nothing calls this directly

Calls 4

newEnforcerWithReaderFunction · 0.85
defaultsForTestFunction · 0.85
IsLimitExceededFunction · 0.85
CheckAgentCreateMethod · 0.65

Tested by

no test coverage detected