| 1 | package agent |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | "path/filepath" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | func TestLoadSessionContextCancelsBeforeSaveLockAdmission(t *testing.T) { |
| 11 | path := filepath.Join(t.TempDir(), "locked.jsonl") |
| 12 | unlock := lockSessionSavePath(path) |
| 13 | defer unlock() |
| 14 | ctx, cancel := context.WithCancel(t.Context()) |
| 15 | cancel() |
| 16 | if _, err := LoadSessionContext(ctx, path); !errors.Is(err, context.Canceled) { |
| 17 | t.Fatalf("cancelled lock admission: %v", err) |
| 18 | } |
| 19 | } |
| 20 |