(t *testing.T)
| 158 | } |
| 159 | |
| 160 | func 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 | |
| 181 | func TestCheckDomainCreate_BlocksAtCap(t *testing.T) { |
| 182 | store := &fakeStore{found: true, row: Limits{MaxAgents: 100, MaxDomains: 1, MaxMessagesMonth: 1, MaxStorageBytes: 1}} |
nothing calls this directly
no test coverage detected