(t *testing.T, params statusTestParams)
| 122 | } |
| 123 | |
| 124 | func statusTest(t *testing.T, params statusTestParams) { |
| 125 | ctx, cancel := context.WithTimeout(context.Background(), testTimeout) |
| 126 | t.Cleanup(cancel) |
| 127 | t.Run(fmt.Sprintf("interval-%s,stability_length-%s", params.cfg.SnapshotInterval, params.cfg.ScreenStabilityLength), func(t *testing.T) { |
| 128 | mClock := quartz.NewMock(t) |
| 129 | params.cfg.Clock = mClock |
| 130 | agent := &testAgent{} |
| 131 | if params.cfg.AgentIO != nil { |
| 132 | if a, ok := params.cfg.AgentIO.(*testAgent); ok { |
| 133 | agent = a |
| 134 | } |
| 135 | } |
| 136 | params.cfg.AgentIO = agent |
| 137 | params.cfg.Logger = slog.New(slog.NewTextHandler(io.Discard, nil)) |
| 138 | |
| 139 | c := st.NewPTY(ctx, params.cfg, &testEmitter{}) |
| 140 | c.Start(ctx) |
| 141 | |
| 142 | assert.Equal(t, st.ConversationStatusInitializing, c.Status()) |
| 143 | |
| 144 | for i, step := range params.steps { |
| 145 | agent.setScreen(step.snapshot) |
| 146 | advanceFor(ctx, t, mClock, params.cfg.SnapshotInterval) |
| 147 | assert.Equal(t, step.status, c.Status(), "step %d", i) |
| 148 | } |
| 149 | }) |
| 150 | } |
| 151 | |
| 152 | func TestConversation(t *testing.T) { |
| 153 | changing := st.ConversationStatusChanging |
no test coverage detected