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

Function TestCheckMessageSend_BlocksOnStorage

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

Source from the content-addressed store, hash-verified

209}
210
211func 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
234func TestCheckMessageSend_MonthCapTakesPrecedenceOverStorage(t *testing.T) {
235 // Both caps hit; the enforcer reports the cheaper-to-explain one.

Callers

nothing calls this directly

Calls 4

newEnforcerWithReaderFunction · 0.85
defaultsForTestFunction · 0.85
IsLimitExceededFunction · 0.85
CheckMessageSendMethod · 0.65

Tested by

no test coverage detected