(t *testing.T)
| 209 | } |
| 210 | |
| 211 | func TestCheckMessageSend_BlocksOnStorage(t *testing.T) { |
| 212 | store := &fakeStore{found: true, row: Limits{MaxAgents: 100, MaxDomains: 100, MaxMessagesMonth: 1_000_000, MaxStorageBytes: 1024 * 1024}} |
| 213 | counter := &fakeCounter{messagesMonth: 10, storageBytes: 1024 * 1024} |
| 214 | e := newEnforcerWithReader(store, counter, defaultsForTest(), 0) |
| 215 | |
| 216 | err := e.CheckMessageSend(context.Background(), "user1") |
| 217 | le, ok := IsLimitExceeded(err) |
| 218 | if !ok { |
| 219 | t.Fatalf("CheckMessageSend at storage cap = %v, want LimitExceededError", err) |
| 220 | } |
| 221 | if le.Resource != "storage" { |
| 222 | t.Errorf("Resource = %q, want storage", le.Resource) |
| 223 | } |
| 224 | // Storage values come through as RAW BYTES (not KB) per the |
| 225 | // resource-natural-unit contract documented on LimitErrorBody. |
| 226 | if le.Limit != 1024*1024 { |
| 227 | t.Errorf("Limit = %d, want %d (bytes)", le.Limit, 1024*1024) |
| 228 | } |
| 229 | if le.Current != 1024*1024 { |
| 230 | t.Errorf("Current = %d, want %d (bytes)", le.Current, 1024*1024) |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | func TestCheckMessageSend_MonthCapTakesPrecedenceOverStorage(t *testing.T) { |
| 235 | // Both caps hit; the enforcer reports the cheaper-to-explain one. |
nothing calls this directly
no test coverage detected