Skip to content

Commit 2fd2110

Browse files
committed
feat: fix tests
1 parent db97306 commit 2fd2110

5 files changed

Lines changed: 23 additions & 18 deletions

File tree

e2e/echo_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func TestE2E(t *testing.T) {
274274
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
275275
defer cancel()
276276

277-
script, apiClient := setup(ctx, t, &params{
277+
script, apiClient, cleanup := setup(ctx, t, &params{
278278
cmdFn: func(ctx context.Context, t testing.TB, serverPort int, binaryPath, cwd, scriptFilePath string) (string, []string) {
279279
return binaryPath, []string{
280280
"server",
@@ -283,7 +283,8 @@ func TestE2E(t *testing.T) {
283283
"--", "go", "run", filepath.Join(cwd, "acp_echo.go"), scriptFilePath,
284284
}
285285
},
286-
})
286+
}, true)
287+
defer cleanup()
287288
messageReq := agentapisdk.PostMessageParams{
288289
Content: "This is a test message.",
289290
Type: agentapisdk.MessageTypeUser,

lib/httpapi/server.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ const snapshotInterval = 25 * time.Millisecond
104104

105105
type ServerConfig struct {
106106
AgentType mf.AgentType
107-
AgentIO st.AgentIO
108-
Transport Transport
107+
AgentIO st.AgentIO
108+
Transport Transport
109109
Port int
110110
ChatBasePath string
111111
AllowedHosts []string
@@ -274,18 +274,19 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) {
274274
return nil, fmt.Errorf("PTY transport requires termexec.Process")
275275
}
276276
conversation = st.NewPTY(ctx, st.PTYConversationConfig{
277-
AgentType: config.AgentType,
278-
AgentIO: proc,
279-
Clock: config.Clock,
280-
SnapshotInterval: snapshotInterval,
281-
ScreenStabilityLength: 2 * time.Second,
282-
FormatMessage: formatMessage,
283-
ReadyForInitialPrompt: isAgentReadyForInitialPrompt,
284-
FormatToolCall: formatToolCall,
285-
InitialPrompt: initialPrompt,
286-
Logger: logger,
287-
StatePersistenceConfig: config.StatePersistenceConfig,
288-
}, emitter)}
277+
AgentType: config.AgentType,
278+
AgentIO: proc,
279+
Clock: config.Clock,
280+
SnapshotInterval: snapshotInterval,
281+
ScreenStabilityLength: 2 * time.Second,
282+
FormatMessage: formatMessage,
283+
ReadyForInitialPrompt: isAgentReadyForInitialPrompt,
284+
FormatToolCall: formatToolCall,
285+
InitialPrompt: initialPrompt,
286+
Logger: logger,
287+
StatePersistenceConfig: config.StatePersistenceConfig,
288+
}, emitter)
289+
}
289290

290291
// Create temporary directory for uploads
291292
tempDir, err := os.MkdirTemp("", "agentapi-uploads-")

lib/httpapi/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ func TestServer_Stop_Idempotency(t *testing.T) {
964964

965965
srv, err := httpapi.NewServer(ctx, httpapi.ServerConfig{
966966
AgentType: msgfmt.AgentTypeClaude,
967-
Process: nil,
967+
AgentIO: nil,
968968
Port: 0,
969969
ChatBasePath: "/chat",
970970
AllowedHosts: []string{"*"},

lib/httpapi/setup.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import (
55
"fmt"
66
"os"
77
"os/exec"
8-
"os/signal"
98
"strings"
9+
"syscall"
10+
"time"
1011

1112
"github.com/coder/agentapi/lib/logctx"
1213
mf "github.com/coder/agentapi/lib/msgfmt"

x/acpio/acp_conversation_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ type mockEmitter struct {
4545
lastScreen string
4646
}
4747

48+
func (m *mockEmitter) EmitError(_ string, _ screentracker.ErrorLevel) {}
49+
4850
func newMockEmitter() *mockEmitter {
4951
m := &mockEmitter{}
5052
m.cond = sync.NewCond(&m.mu)

0 commit comments

Comments
 (0)