| 1 | package agent |
| 2 | |
| 3 | import ( |
| 4 | "path/filepath" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestSessionModelSelectionRoundTrip(t *testing.T) { |
| 9 | path := filepath.Join(t.TempDir(), "session.jsonl") |
| 10 | if err := SetBranchModelPreserveUpdated(path, "go/model"); err != nil { |
| 11 | t.Fatal(err) |
| 12 | } |
| 13 | before, _, _ := LoadBranchMeta(path) |
| 14 | if model, identity, ok := LoadSessionModelSelection(path); !ok || model != "go/model" || identity != "" { |
| 15 | t.Fatal("legacy model must have no acknowledgement") |
| 16 | } |
| 17 | if err := SetBranchModelSelectionPreserveUpdated(path, "go/model", "acknowledged"); err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | if err := UpdateSessionMeta(path, "go/model", "preview", 1, false); err != nil { |
| 21 | t.Fatal(err) |
| 22 | } |
| 23 | after, _, _ := LoadBranchMeta(path) |
| 24 | if after.ModelIdentity != "acknowledged" || !after.UpdatedAt.Equal(before.UpdatedAt) { |
| 25 | t.Fatal("listing update lost identity or changed activity") |
| 26 | } |
| 27 | if err := SetBranchModelPreserveUpdated(path, "go/other"); err != nil { |
| 28 | t.Fatal(err) |
| 29 | } |
| 30 | if _, identity, _ := LoadSessionModelSelection(path); identity != "" { |
| 31 | t.Fatal("old acknowledgement must not attach to another model") |
| 32 | } |
| 33 | } |
| 34 |