(t *testing.T)
| 1315 | t.Fatalf("restore should prepend consumed edits back to pending, got %#v", snapshot) |
| 1316 | } |
| 1317 | |
| 1318 | options = engine.ConsumeCacheEditsForRequest(map[string]struct{}{"stale-1": {}}) |
| 1319 | if len(options.AnthropicCacheEdits) != 1 { |
| 1320 | t.Fatalf("restored edit should be consumed again, got %#v", options) |
| 1321 | } |
| 1322 | engine.PinConsumedCacheEdits() |
| 1323 | snapshot = engine.CacheEditStateSnapshot() |
| 1324 | if len(snapshot.Pending) != 0 || len(snapshot.ConsumedInFlight) != 0 || len(snapshot.Pinned) != 1 { |
| 1325 | t.Fatalf("successful request should pin consumed edit, got %#v", snapshot) |
| 1326 | } |
| 1327 | |
| 1328 | options = engine.ConsumeCacheEditsForRequest(map[string]struct{}{"stale-1": {}}) |
| 1329 | if len(options.AnthropicCacheEdits) != 1 || options.AnthropicCacheEdits[0].ToolUseID != "stale-1" { |
| 1330 | t.Fatalf("pinned edit should be reused while visible, got %#v", options) |
| 1331 | } |
| 1332 | options = engine.ConsumeCacheEditsForRequest(map[string]struct{}{}) |
| 1333 | if len(options.AnthropicCacheEdits) != 0 || len(engine.CacheEditStateSnapshot().Pinned) != 0 { |
| 1334 | t.Fatalf("invisible pinned edits should be pruned, got %#v state=%#v", options, engine.CacheEditStateSnapshot()) |
| 1335 | } |
| 1336 | |
| 1337 | cfg.APIModel = "gpt-5" |
| 1338 | engine = agent.NewCoreExecutionEngine(&cfg) |
| 1339 | engine.QueueCacheEdits([]agentContext.CacheEdit{agentContext.NewCacheEdit("stale-2", nil)}) |
| 1340 | options = engine.ConsumeCacheEditsForRequest(map[string]struct{}{"stale-2": {}}) |
| 1341 | if len(options.AnthropicCacheEdits) != 0 || len(engine.CacheEditStateSnapshot().Pending) != 0 { |
| 1342 | t.Fatalf("non-Claude models should clear runtime cache edits, got %#v state=%#v", options, engine.CacheEditStateSnapshot()) |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | func runGit(t *testing.T, dir string, args ...string) { |
| 1347 | t.Helper() |
| 1348 | cmd := exec.Command("git", args...) |
| 1349 | cmd.Dir = dir |
| 1350 | if out, err := cmd.CombinedOutput(); err != nil { |
| 1351 | t.Fatalf("git %v failed: %v\n%s", args, err, out) |
| 1352 | } |
| 1353 | } |
nothing calls this directly
no test coverage detected