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

Function TestEnforcer_CacheServesFromMemoryWithinTTL

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

Source from the content-addressed store, hash-verified

122}
123
124func TestEnforcer_CacheServesFromMemoryWithinTTL(t *testing.T) {
125 store := &fakeStore{found: true, row: Limits{PlanCode: "p", MaxAgents: 1, MaxDomains: 1, MaxMessagesMonth: 1, MaxStorageBytes: 1}}
126 e := newEnforcerWithReader(store, &fakeCounter{}, defaultsForTest(), time.Minute)
127
128 for i := 0; i < 5; i++ {
129 if _, err := e.Get(context.Background(), "user1"); err != nil {
130 t.Fatalf("Get: %v", err)
131 }
132 }
133 if store.calls != 1 {
134 t.Errorf("store hit %d times, want 1 (cache should serve subsequent)", store.calls)
135 }
136}
137
138func TestEnforcer_InvalidateClearsCachedRow(t *testing.T) {
139 store := &fakeStore{found: true, row: Limits{MaxAgents: 1, MaxDomains: 1, MaxMessagesMonth: 1, MaxStorageBytes: 1}}

Callers

nothing calls this directly

Calls 3

newEnforcerWithReaderFunction · 0.85
defaultsForTestFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected