Skip to content

Commit 341a8ea

Browse files
Apply gofmt
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7861d14 commit 341a8ea

4 files changed

Lines changed: 122 additions & 122 deletions

File tree

go/client_test.go

Lines changed: 110 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -20,118 +20,118 @@ import (
2020
// This file is for unit tests. Where relevant, prefer to add e2e tests in e2e/*.test.go instead
2121

2222
func TestClient_URLParsing(t *testing.T) {
23-
t.Run("should parse port-only URL format", func(t *testing.T) {
24-
client := NewClient(&ClientOptions{
25-
Connection: UriConnection{URL: "8080"},
26-
})
27-
if client.actualPort != 8080 {
28-
t.Errorf("Expected port 8080, got %d", client.actualPort)
29-
}
30-
if client.actualHost != "localhost" {
31-
t.Errorf("Expected host localhost, got %s", client.actualHost)
32-
}
33-
if !client.isExternalServer {
34-
t.Error("Expected isExternalServer to be true")
35-
}
36-
})
37-
38-
t.Run("should parse host:port URL format", func(t *testing.T) {
39-
client := NewClient(&ClientOptions{
40-
Connection: UriConnection{URL: "127.0.0.1:9000"},
41-
})
42-
if client.actualPort != 9000 || client.actualHost != "127.0.0.1" {
43-
t.Errorf("Expected 127.0.0.1:9000, got %s:%d", client.actualHost, client.actualPort)
44-
}
45-
})
46-
47-
t.Run("should parse http://host:port URL format", func(t *testing.T) {
48-
client := NewClient(&ClientOptions{
49-
Connection: UriConnection{URL: "http://localhost:7000"},
50-
})
51-
if client.actualPort != 7000 || client.actualHost != "localhost" {
52-
t.Errorf("Expected localhost:7000, got %s:%d", client.actualHost, client.actualPort)
53-
}
54-
})
55-
56-
t.Run("should parse https://host:port URL format", func(t *testing.T) {
57-
client := NewClient(&ClientOptions{
58-
Connection: UriConnection{URL: "https://example.com:443"},
59-
})
60-
if client.actualPort != 443 || client.actualHost != "example.com" {
61-
t.Errorf("Expected example.com:443, got %s:%d", client.actualHost, client.actualPort)
62-
}
63-
})
23+
t.Run("should parse port-only URL format", func(t *testing.T) {
24+
client := NewClient(&ClientOptions{
25+
Connection: UriConnection{URL: "8080"},
26+
})
27+
if client.actualPort != 8080 {
28+
t.Errorf("Expected port 8080, got %d", client.actualPort)
29+
}
30+
if client.actualHost != "localhost" {
31+
t.Errorf("Expected host localhost, got %s", client.actualHost)
32+
}
33+
if !client.isExternalServer {
34+
t.Error("Expected isExternalServer to be true")
35+
}
36+
})
6437

65-
t.Run("should panic for invalid URL format", func(t *testing.T) {
66-
defer func() {
67-
if r := recover(); r == nil {
68-
t.Error("Expected panic for invalid URL format")
69-
}
70-
}()
71-
NewClient(&ClientOptions{Connection: UriConnection{URL: "invalid-url"}})
72-
})
73-
74-
t.Run("should panic for invalid port - too high", func(t *testing.T) {
75-
defer func() {
76-
if r := recover(); r == nil {
77-
t.Error("Expected panic")
78-
}
79-
}()
80-
NewClient(&ClientOptions{Connection: UriConnection{URL: "localhost:99999"}})
81-
})
82-
83-
t.Run("should panic for invalid port - zero", func(t *testing.T) {
84-
defer func() {
85-
if r := recover(); r == nil {
86-
t.Error("Expected panic")
87-
}
88-
}()
89-
NewClient(&ClientOptions{Connection: UriConnection{URL: "localhost:0"}})
90-
})
91-
92-
t.Run("should panic for invalid port - negative", func(t *testing.T) {
93-
defer func() {
94-
if r := recover(); r == nil {
95-
t.Error("Expected panic")
96-
}
97-
}()
98-
NewClient(&ClientOptions{Connection: UriConnection{URL: "localhost:-1"}})
99-
})
100-
101-
t.Run("should panic when UriConnection has empty URL", func(t *testing.T) {
102-
defer func() {
103-
if r := recover(); r == nil {
104-
t.Error("Expected panic for empty URL")
105-
}
106-
}()
107-
NewClient(&ClientOptions{Connection: UriConnection{}})
108-
})
109-
110-
t.Run("stdio connection uses stdio transport", func(t *testing.T) {
111-
client := NewClient(&ClientOptions{Connection: StdioConnection{}})
112-
if !client.useStdio {
113-
t.Error("Expected useStdio=true for StdioConnection")
114-
}
115-
})
38+
t.Run("should parse host:port URL format", func(t *testing.T) {
39+
client := NewClient(&ClientOptions{
40+
Connection: UriConnection{URL: "127.0.0.1:9000"},
41+
})
42+
if client.actualPort != 9000 || client.actualHost != "127.0.0.1" {
43+
t.Errorf("Expected 127.0.0.1:9000, got %s:%d", client.actualHost, client.actualPort)
44+
}
45+
})
11646

117-
t.Run("tcp connection uses tcp transport", func(t *testing.T) {
118-
client := NewClient(&ClientOptions{Connection: TcpConnection{Port: 8080}})
119-
if client.useStdio {
120-
t.Error("Expected useStdio=false for TcpConnection")
121-
}
122-
if client.port != 8080 {
123-
t.Errorf("Expected port=8080, got %d", client.port)
124-
}
125-
})
126-
127-
t.Run("uri connection is treated as external server", func(t *testing.T) {
128-
client := NewClient(&ClientOptions{
129-
Connection: UriConnection{URL: "localhost:8080"},
130-
})
131-
if !client.isExternalServer {
132-
t.Error("Expected isExternalServer=true for UriConnection")
133-
}
134-
})
47+
t.Run("should parse http://host:port URL format", func(t *testing.T) {
48+
client := NewClient(&ClientOptions{
49+
Connection: UriConnection{URL: "http://localhost:7000"},
50+
})
51+
if client.actualPort != 7000 || client.actualHost != "localhost" {
52+
t.Errorf("Expected localhost:7000, got %s:%d", client.actualHost, client.actualPort)
53+
}
54+
})
55+
56+
t.Run("should parse https://host:port URL format", func(t *testing.T) {
57+
client := NewClient(&ClientOptions{
58+
Connection: UriConnection{URL: "https://example.com:443"},
59+
})
60+
if client.actualPort != 443 || client.actualHost != "example.com" {
61+
t.Errorf("Expected example.com:443, got %s:%d", client.actualHost, client.actualPort)
62+
}
63+
})
64+
65+
t.Run("should panic for invalid URL format", func(t *testing.T) {
66+
defer func() {
67+
if r := recover(); r == nil {
68+
t.Error("Expected panic for invalid URL format")
69+
}
70+
}()
71+
NewClient(&ClientOptions{Connection: UriConnection{URL: "invalid-url"}})
72+
})
73+
74+
t.Run("should panic for invalid port - too high", func(t *testing.T) {
75+
defer func() {
76+
if r := recover(); r == nil {
77+
t.Error("Expected panic")
78+
}
79+
}()
80+
NewClient(&ClientOptions{Connection: UriConnection{URL: "localhost:99999"}})
81+
})
82+
83+
t.Run("should panic for invalid port - zero", func(t *testing.T) {
84+
defer func() {
85+
if r := recover(); r == nil {
86+
t.Error("Expected panic")
87+
}
88+
}()
89+
NewClient(&ClientOptions{Connection: UriConnection{URL: "localhost:0"}})
90+
})
91+
92+
t.Run("should panic for invalid port - negative", func(t *testing.T) {
93+
defer func() {
94+
if r := recover(); r == nil {
95+
t.Error("Expected panic")
96+
}
97+
}()
98+
NewClient(&ClientOptions{Connection: UriConnection{URL: "localhost:-1"}})
99+
})
100+
101+
t.Run("should panic when UriConnection has empty URL", func(t *testing.T) {
102+
defer func() {
103+
if r := recover(); r == nil {
104+
t.Error("Expected panic for empty URL")
105+
}
106+
}()
107+
NewClient(&ClientOptions{Connection: UriConnection{}})
108+
})
109+
110+
t.Run("stdio connection uses stdio transport", func(t *testing.T) {
111+
client := NewClient(&ClientOptions{Connection: StdioConnection{}})
112+
if !client.useStdio {
113+
t.Error("Expected useStdio=true for StdioConnection")
114+
}
115+
})
116+
117+
t.Run("tcp connection uses tcp transport", func(t *testing.T) {
118+
client := NewClient(&ClientOptions{Connection: TcpConnection{Port: 8080}})
119+
if client.useStdio {
120+
t.Error("Expected useStdio=false for TcpConnection")
121+
}
122+
if client.port != 8080 {
123+
t.Errorf("Expected port=8080, got %d", client.port)
124+
}
125+
})
126+
127+
t.Run("uri connection is treated as external server", func(t *testing.T) {
128+
client := NewClient(&ClientOptions{
129+
Connection: UriConnection{URL: "localhost:8080"},
130+
})
131+
if !client.isExternalServer {
132+
t.Error("Expected isExternalServer=true for UriConnection")
133+
}
134+
})
135135
}
136136

137137
func TestClient_SessionFsConfig(t *testing.T) {

go/internal/e2e/commands_and_elicitation_e2e_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestCommandsE2E(t *testing.T) {
6363
// Client2 joins with commands
6464
session2, err := client2.ResumeSession(t.Context(), session1.SessionID, &copilot.ResumeSessionConfig{
6565
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
66-
SuppressResumeEvent: true,
66+
SuppressResumeEvent: true,
6767
Commands: []copilot.CommandDefinition{
6868
{
6969
Name: "deploy",
@@ -560,7 +560,7 @@ func TestUIElicitationMultiClientE2E(t *testing.T) {
560560
})
561561
session2, err := client2.ResumeSession(t.Context(), session1.SessionID, &copilot.ResumeSessionConfig{
562562
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
563-
SuppressResumeEvent: true,
563+
SuppressResumeEvent: true,
564564
OnElicitationRequest: func(ctx copilot.ElicitationContext) (copilot.ElicitationResult, error) {
565565
return copilot.ElicitationResult{Action: "accept", Content: map[string]any{}}, nil
566566
},
@@ -620,7 +620,7 @@ func TestUIElicitationMultiClientE2E(t *testing.T) {
620620
})
621621
_, err = client3.ResumeSession(t.Context(), session1.SessionID, &copilot.ResumeSessionConfig{
622622
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
623-
SuppressResumeEvent: true,
623+
SuppressResumeEvent: true,
624624
OnElicitationRequest: func(ctx copilot.ElicitationContext) (copilot.ElicitationResult, error) {
625625
return copilot.ElicitationResult{Action: "accept", Content: map[string]any{}}, nil
626626
},

go/internal/e2e/session_fs_e2e_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestSessionFsE2E(t *testing.T) {
4343
ctx.ConfigureForTest(t)
4444

4545
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
46-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
46+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
4747
CreateSessionFsProvider: createSessionFsHandler,
4848
})
4949
if err != nil {
@@ -80,7 +80,7 @@ func TestSessionFsE2E(t *testing.T) {
8080
ctx.ConfigureForTest(t)
8181

8282
session1, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
83-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
83+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
8484
CreateSessionFsProvider: createSessionFsHandler,
8585
})
8686
if err != nil {
@@ -110,7 +110,7 @@ func TestSessionFsE2E(t *testing.T) {
110110
}
111111

112112
session2, err := client.ResumeSession(t.Context(), sessionID, &copilot.ResumeSessionConfig{
113-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
113+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
114114
CreateSessionFsProvider: createSessionFsHandler,
115115
})
116116
if err != nil {
@@ -172,7 +172,7 @@ func TestSessionFsE2E(t *testing.T) {
172172

173173
suppliedFileContent := strings.Repeat("x", 100_000)
174174
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
175-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
175+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
176176
CreateSessionFsProvider: createSessionFsHandler,
177177
Tools: []copilot.Tool{
178178
copilot.DefineTool("get_big_string", "Returns a large string",
@@ -217,7 +217,7 @@ func TestSessionFsE2E(t *testing.T) {
217217
ctx.ConfigureForTest(t)
218218

219219
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
220-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
220+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
221221
CreateSessionFsProvider: createSessionFsHandler,
222222
})
223223
if err != nil {
@@ -256,7 +256,7 @@ func TestSessionFsE2E(t *testing.T) {
256256
ctx.ConfigureForTest(t)
257257

258258
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
259-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
259+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
260260
CreateSessionFsProvider: createSessionFsHandler,
261261
})
262262
if err != nil {
@@ -298,7 +298,7 @@ func TestSessionFsE2E(t *testing.T) {
298298
ctx.ConfigureForTest(t)
299299

300300
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
301-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
301+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
302302
CreateSessionFsProvider: createSessionFsHandler,
303303
})
304304
if err != nil {

go/internal/e2e/session_fs_sqlite_e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func TestSessionFsSqliteE2E(t *testing.T) {
268268
sqliteCalls = nil
269269

270270
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
271-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
271+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
272272
CreateSessionFsProvider: createSessionFsHandler,
273273
})
274274
if err != nil {
@@ -306,7 +306,7 @@ func TestSessionFsSqliteE2E(t *testing.T) {
306306
sqliteCalls = nil
307307

308308
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
309-
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
309+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
310310
CreateSessionFsProvider: createSessionFsHandler,
311311
})
312312
if err != nil {

0 commit comments

Comments
 (0)