MCPcopy Create free account
hub / github.com/coder/agentapi / statusTest

Function statusTest

lib/screentracker/pty_conversation_test.go:124–150  ·  view source on GitHub ↗
(t *testing.T, params statusTestParams)

Source from the content-addressed store, hash-verified

122}
123
124func 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
152func TestConversation(t *testing.T) {
153 changing := st.ConversationStatusChanging

Callers 1

TestConversationFunction · 0.85

Calls 4

setScreenMethod · 0.95
advanceForFunction · 0.85
StartMethod · 0.65
StatusMethod · 0.65

Tested by

no test coverage detected