(t *testing.T)
| 122 | } |
| 123 | |
| 124 | func 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 | |
| 138 | func TestEnforcer_InvalidateClearsCachedRow(t *testing.T) { |
| 139 | store := &fakeStore{found: true, row: Limits{MaxAgents: 1, MaxDomains: 1, MaxMessagesMonth: 1, MaxStorageBytes: 1}} |
nothing calls this directly
no test coverage detected