(t *testing.T)
| 3233 | } |
| 3234 | |
| 3235 | func Test_GetIssueComments(t *testing.T) { |
| 3236 | // Verify tool definition once |
| 3237 | serverTool := IssueRead(translations.NullTranslationHelper) |
| 3238 | tool := serverTool.Tool |
| 3239 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 3240 | |
| 3241 | assert.Equal(t, "issue_read", tool.Name) |
| 3242 | assert.NotEmpty(t, tool.Description) |
| 3243 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "method") |
| 3244 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner") |
| 3245 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo") |
| 3246 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "issue_number") |
| 3247 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "page") |
| 3248 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "perPage") |
| 3249 | assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"method", "owner", "repo", "issue_number"}) |
| 3250 | |
| 3251 | // Setup mock comments for success case |
| 3252 | mockComments := []*github.IssueComment{ |
| 3253 | { |
| 3254 | ID: github.Ptr(int64(123)), |
| 3255 | Body: github.Ptr("This is the first comment"), |
| 3256 | User: &github.User{ |
| 3257 | Login: github.Ptr("user1"), |
| 3258 | }, |
| 3259 | CreatedAt: &github.Timestamp{Time: time.Now().Add(-time.Hour * 24)}, |
| 3260 | }, |
| 3261 | { |
| 3262 | ID: github.Ptr(int64(456)), |
| 3263 | Body: github.Ptr("This is the second comment"), |
| 3264 | User: &github.User{ |
| 3265 | Login: github.Ptr("user2"), |
| 3266 | }, |
| 3267 | CreatedAt: &github.Timestamp{Time: time.Now().Add(-time.Hour)}, |
| 3268 | }, |
| 3269 | } |
| 3270 | |
| 3271 | tests := []struct { |
| 3272 | name string |
| 3273 | mockedClient *http.Client |
| 3274 | requestArgs map[string]any |
| 3275 | expectError bool |
| 3276 | expectedComments []*github.IssueComment |
| 3277 | expectedErrMsg string |
| 3278 | lockdownEnabled bool |
| 3279 | }{ |
| 3280 | { |
| 3281 | name: "successful comments retrieval", |
| 3282 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 3283 | GetReposIssuesCommentsByOwnerByRepoByIssueNumber: mockResponse(t, http.StatusOK, mockComments), |
| 3284 | }), |
| 3285 | requestArgs: map[string]any{ |
| 3286 | "method": "get_comments", |
| 3287 | "owner": "owner", |
| 3288 | "repo": "repo", |
| 3289 | "issue_number": float64(42), |
| 3290 | }, |
| 3291 | expectError: false, |
| 3292 | expectedComments: mockComments, |
nothing calls this directly
no test coverage detected