MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestBasicEngine_RateLimit

Function TestBasicEngine_RateLimit

internal/policy/basic_engine_test.go:73–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestBasicEngine_RateLimit(t *testing.T) {
74 engine := NewBasicEngine(testConfig())
75
76 first, _ := engine.Evaluate(context.Background(), types.AIRequest{
77 TenantID: "team-a",
78 TaskType: "simple",
79 Options: types.RequestOptions{MaxTokens: 128},
80 })
81 second, _ := engine.Evaluate(context.Background(), types.AIRequest{
82 TenantID: "team-a",
83 TaskType: "simple",
84 Options: types.RequestOptions{MaxTokens: 128},
85 })
86
87 if !first.Allowed {
88 t.Fatalf("first request should pass")
89 }
90 if second.Allowed {
91 t.Fatalf("second request should be rate-limited")
92 }
93}
94
95func TestBasicEngine_BudgetExceeded(t *testing.T) {
96 engine := NewBasicEngine(testConfig())

Callers

nothing calls this directly

Calls 3

EvaluateMethod · 0.95
NewBasicEngineFunction · 0.85
testConfigFunction · 0.70

Tested by

no test coverage detected