@@ -66,15 +66,23 @@ func TestHandleListProjects(t *testing.T) {
66
66
t .Fatal ("expected successful result, got error" )
67
67
}
68
68
69
- // Check that tokens are now included in response
69
+ // Verify the response can be unmarshaled as a projects list response
70
70
resultText := getResultText (result )
71
- if ! strings .Contains (resultText , "secret123" ) {
72
- t .Error ("Token should be included in response" )
71
+ var response hbapi.ProjectsResponse
72
+ if err := json .Unmarshal ([]byte (resultText ), & response ); err != nil {
73
+ t .Errorf ("Response should be valid JSON projects list response: %v" , err )
74
+ }
75
+
76
+ if len (response .Results ) != 2 {
77
+ t .Errorf ("expected 2 projects, got %d" , len (response .Results ))
73
78
}
74
79
75
- // Check that project data is still present
76
- if ! strings .Contains (resultText , "Project 1" ) {
77
- t .Error ("Project name should be present in response" )
80
+ if response .Results [0 ].Name != "Project 1" {
81
+ t .Errorf ("expected first project name 'Project 1', got %s" , response .Results [0 ].Name )
82
+ }
83
+
84
+ if response .Results [1 ].Name != "Project 2" {
85
+ t .Errorf ("expected second project name 'Project 2', got %s" , response .Results [1 ].Name )
78
86
}
79
87
}
80
88
@@ -135,7 +143,6 @@ func TestHandleListProjects_WithAccountID(t *testing.T) {
135
143
WithBaseURL (server .URL ).
136
144
WithAuthToken ("test-token" )
137
145
138
- // Test with account_id parameter
139
146
req := mcp.CallToolRequest {
140
147
Params : mcp.CallToolParams {
141
148
Arguments : map [string ]interface {}{
@@ -153,15 +160,23 @@ func TestHandleListProjects_WithAccountID(t *testing.T) {
153
160
t .Fatal ("expected successful result, got error" )
154
161
}
155
162
156
- // Check that tokens are now included in response
163
+ // Verify the response can be unmarshaled as a projects list response
157
164
resultText := getResultText (result )
158
- if ! strings .Contains (resultText , "secret123" ) {
159
- t .Error ("Token should be included in response" )
165
+ var response hbapi.ProjectsResponse
166
+ if err := json .Unmarshal ([]byte (resultText ), & response ); err != nil {
167
+ t .Errorf ("Response should be valid JSON projects list response: %v" , err )
160
168
}
161
169
162
- // Check that project data is still present
163
- if ! strings .Contains (resultText , "Project 1" ) {
164
- t .Error ("Project name should be present in response" )
170
+ if len (response .Results ) != 1 {
171
+ t .Errorf ("expected 1 project, got %d" , len (response .Results ))
172
+ }
173
+
174
+ if response .Results [0 ].Name != "Project 1" {
175
+ t .Errorf ("expected project name 'Project 1', got %s" , response .Results [0 ].Name )
176
+ }
177
+
178
+ if response .Results [0 ].ID != 1 {
179
+ t .Errorf ("expected project ID 1, got %d" , response .Results [0 ].ID )
165
180
}
166
181
}
167
182
@@ -202,14 +217,23 @@ func TestHandleGetProject(t *testing.T) {
202
217
t .Fatal ("expected successful result, got error" )
203
218
}
204
219
205
- // Check that token is now included in response
206
- if ! strings .Contains (getResultText (result ), "secret123" ) {
207
- t .Error ("Token should be included in response" )
220
+ // Verify the response can be unmarshaled as a project
221
+ resultText := getResultText (result )
222
+ var project hbapi.Project
223
+ if err := json .Unmarshal ([]byte (resultText ), & project ); err != nil {
224
+ t .Errorf ("Response should be valid JSON project: %v" , err )
208
225
}
209
226
210
- // Check that project data is still present
211
- if ! strings .Contains (getResultText (result ), "Test Project" ) {
212
- t .Error ("Project name should be present in response" )
227
+ if project .ID != 123 {
228
+ t .Errorf ("expected project ID 123, got %d" , project .ID )
229
+ }
230
+
231
+ if project .Name != "Test Project" {
232
+ t .Errorf ("expected project name 'Test Project', got %s" , project .Name )
233
+ }
234
+
235
+ if ! project .Active {
236
+ t .Error ("expected project to be active" )
213
237
}
214
238
}
215
239
@@ -318,14 +342,27 @@ func TestHandleCreateProject(t *testing.T) {
318
342
t .Fatal ("expected successful result, got error" )
319
343
}
320
344
321
- // Check that API key is now included in response
322
- if ! strings .Contains (getResultText (result ), "secret789" ) {
323
- t .Error ("API key should be included in response" )
345
+ // Verify the response can be unmarshaled as a project
346
+ resultText := getResultText (result )
347
+ var project hbapi.Project
348
+ if err := json .Unmarshal ([]byte (resultText ), & project ); err != nil {
349
+ t .Errorf ("Response should be valid JSON project: %v" , err )
350
+ }
351
+
352
+ if project .ID != 456 {
353
+ t .Errorf ("expected project ID 456, got %d" , project .ID )
324
354
}
325
355
326
- // Check that project data is still present
327
- if ! strings .Contains (getResultText (result ), "New Project" ) {
328
- t .Error ("Project name should be present in response" )
356
+ if project .Name != "New Project" {
357
+ t .Errorf ("expected project name 'New Project', got %s" , project .Name )
358
+ }
359
+
360
+ if ! project .Active {
361
+ t .Error ("expected created project to be active" )
362
+ }
363
+
364
+ if project .Owner .Email != "user@example.com" {
365
+ t .Errorf ("expected owner email 'user@example.com', got %s" , project .Owner .Email )
329
366
}
330
367
}
331
368
@@ -616,7 +653,6 @@ func TestHandleDeleteProject_Error(t *testing.T) {
616
653
}
617
654
}
618
655
619
-
620
656
func TestHandleGetProjectReport (t * testing.T ) {
621
657
mockResponse := `[["RuntimeError", 8347], ["SocketError", 4651]]`
622
658
0 commit comments