(t *testing.T)
| 61 | } |
| 62 | |
| 63 | func TestFallbackCooldown_UsesInjectedClock(t *testing.T) { |
| 64 | t.Parallel() |
| 65 | |
| 66 | prov := &mockProvider{id: "test/mock-model"} |
| 67 | root := agent.New("root", "test", agent.WithModel(prov)) |
| 68 | tm := team.New(team.WithAgents(root)) |
| 69 | |
| 70 | clock := newFakeClock(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)) |
| 71 | rt, err := NewLocalRuntime(t.Context(), tm, |
| 72 | WithClock(clock.Now), |
| 73 | WithModelStore(mockModelStore{}), |
| 74 | ) |
| 75 | require.NoError(t, err) |
| 76 | |
| 77 | // Activate cooldown for 1 minute against a fallback at index 0. |
| 78 | rt.fallback.cooldowns.Set("root", 0, time.Minute) |
| 79 | require.NotNil(t, rt.fallback.cooldowns.Get("root"), "cooldown should be active") |
| 80 | |
| 81 | // Advance just under the window: still active. |
| 82 | clock.Advance(59 * time.Second) |
| 83 | assert.NotNil(t, rt.fallback.cooldowns.Get("root"), "cooldown expired prematurely") |
| 84 | |
| 85 | // Advance past expiry: cooldowns.Get evicts and returns nil. |
| 86 | clock.Advance(2 * time.Second) |
| 87 | assert.Nil(t, rt.fallback.cooldowns.Get("root"), "expired cooldown not evicted") |
| 88 | } |
nothing calls this directly
no test coverage detected