Assert both terminal session endings after marker replacement
1 file changed,
+37
−2
internal/console/apiinteractive_test.go+37 −2
CI failed — run details
diff --git a/internal/console/apiinteractive_test.go b/internal/console/apiinteractive_test.go| index 16944ad8f..ec2d0cfa3 100644 |
| --- a/internal/console/apiinteractive_test.go |
| +++ b/internal/console/apiinteractive_test.go |
| @@ -422,11 +422,46 @@ func TestInteractiveRefusalsInOrder(t *testing.T) { |
| } |
| } |
| // With the live marker's session gone from the hub, the same request is |
| - // admitted: the walk's world was otherwise whole. |
| + // admitted: the walk's world was otherwise whole. release only dropped |
| + // the hub's copy, so the admission's write still finds Bob's marker in |
| + // the record and owes it an end row of its own: lost, alongside Alice's |
| + // new session ending cancelled. |
| s.interactive.release(liveID) |
| ws := ixStart(t, fx, fx.alice, ixOpenArgv()) |
| + defer ws.Close() |
| + after, _ := ixRecord(t, fx, ixHost) |
| + if after.Interactive == nil || after.Interactive.ID == liveID { |
| + t.Fatalf("the admitted session's marker: %+v, want a fresh id replacing %s", after.Interactive, liveID) |
| + } |
| + newID := after.Interactive.ID |
| ws.Close() |
| - ixWaitEvents(t, fx, "interactive-end", 1) |
| + |
| + // Exactly one end row for each of the two known ids, and nothing else: |
| + // Bob's old marker lost, Alice's new session cancelled. |
| + want := map[string]struct{ reason, by string }{ |
| + liveID: {interactive.EndLost, "bob@keymail.dev"}, |
| + newID: {interactive.EndCancelled, "alice@keymail.dev"}, |
| + } |
| + seen := map[string]bool{} |
| + for _, e := range ixWaitEvents(t, fx, "interactive-end", 2) { |
| + d := ixEndRow(t, e) |
| + if seen[d.ID] { |
| + t.Fatalf("interactive-end: a second row for %s: %+v", d.ID, e) |
| + } |
| + seen[d.ID] = true |
| + w, ok := want[d.ID] |
| + if !ok { |
| + t.Fatalf("interactive-end: unknown id %s: %+v", d.ID, e) |
| + } |
| + if d.Reason != w.reason || e.Address != w.by { |
| + t.Errorf("interactive-end %s: reason %q by %q, want %q by %q", d.ID, d.Reason, e.Address, w.reason, w.by) |
| + } |
| + } |
| + for id := range want { |
| + if !seen[id] { |
| + t.Errorf("interactive-end: no row for %s", id) |
| + } |
| + } |
| } |
| func TestInteractiveOnAHostClaimConsole(t *testing.T) { |