(t *testing.T)
| 279 | } |
| 280 | |
| 281 | func Test_IssueRead_IFC_InsidersMode(t *testing.T) { |
| 282 | t.Parallel() |
| 283 | |
| 284 | serverTool := IssueRead(translations.NullTranslationHelper) |
| 285 | |
| 286 | mockIssue := &github.Issue{ |
| 287 | Number: github.Ptr(1), |
| 288 | Title: github.Ptr("Test"), |
| 289 | Body: github.Ptr("body"), |
| 290 | State: github.Ptr("open"), |
| 291 | HTMLURL: github.Ptr("https://github.com/octocat/repo/issues/1"), |
| 292 | User: &github.User{Login: github.Ptr("u")}, |
| 293 | } |
| 294 | |
| 295 | mockComments := []*github.IssueComment{ |
| 296 | {Body: github.Ptr("hello"), User: &github.User{Login: github.Ptr("u")}}, |
| 297 | } |
| 298 | |
| 299 | makeMockClient := func(isPrivate bool, repoStatus int) *http.Client { |
| 300 | handlers := map[string]http.HandlerFunc{ |
| 301 | GetReposIssuesByOwnerByRepoByIssueNumber: mockResponse(t, http.StatusOK, mockIssue), |
| 302 | GetReposIssuesCommentsByOwnerByRepoByIssueNumber: mockResponse(t, http.StatusOK, mockComments), |
| 303 | } |
| 304 | if repoStatus != 0 && repoStatus != http.StatusOK { |
| 305 | handlers[GetReposByOwnerByRepo] = mockResponse(t, repoStatus, "boom") |
| 306 | } else { |
| 307 | handlers[GetReposByOwnerByRepo] = mockResponse(t, http.StatusOK, map[string]any{ |
| 308 | "name": "repo", |
| 309 | "private": isPrivate, |
| 310 | }) |
| 311 | } |
| 312 | return MockHTTPClientWithHandlers(handlers) |
| 313 | } |
| 314 | |
| 315 | getReq := map[string]any{ |
| 316 | "method": "get", |
| 317 | "owner": "octocat", |
| 318 | "repo": "repo", |
| 319 | "issue_number": float64(1), |
| 320 | } |
| 321 | commentsReq := map[string]any{ |
| 322 | "method": "get_comments", |
| 323 | "owner": "octocat", |
| 324 | "repo": "repo", |
| 325 | "issue_number": float64(1), |
| 326 | } |
| 327 | |
| 328 | t.Run("insiders mode disabled omits ifc label", func(t *testing.T) { |
| 329 | deps := BaseDeps{ |
| 330 | Client: mustNewGHClient(t, makeMockClient(false, 0)), |
| 331 | } |
| 332 | handler := serverTool.Handler(deps) |
| 333 | |
| 334 | request := createMCPRequest(getReq) |
| 335 | result, err := handler(ContextWithDeps(context.Background(), deps), &request) |
| 336 | require.NoError(t, err) |
| 337 | require.False(t, result.IsError) |
| 338 |
nothing calls this directly
no test coverage detected