(t *testing.T)
| 851 | } |
| 852 | |
| 853 | func Test_RequestCopilotReview(t *testing.T) { |
| 854 | t.Parallel() |
| 855 | |
| 856 | serverTool := RequestCopilotReview(translations.NullTranslationHelper) |
| 857 | tool := serverTool.Tool |
| 858 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 859 | |
| 860 | assert.Equal(t, "request_copilot_review", tool.Name) |
| 861 | assert.NotEmpty(t, tool.Description) |
| 862 | schema := tool.InputSchema.(*jsonschema.Schema) |
| 863 | assert.Contains(t, schema.Properties, "owner") |
| 864 | assert.Contains(t, schema.Properties, "repo") |
| 865 | assert.Contains(t, schema.Properties, "pullNumber") |
| 866 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo", "pullNumber"}) |
| 867 | |
| 868 | // Setup mock PR for success case |
| 869 | mockPR := &github.PullRequest{ |
| 870 | Number: github.Ptr(42), |
| 871 | Title: github.Ptr("Test PR"), |
| 872 | State: github.Ptr("open"), |
| 873 | HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42"), |
| 874 | Head: &github.PullRequestBranch{ |
| 875 | SHA: github.Ptr("abcd1234"), |
| 876 | Ref: github.Ptr("feature-branch"), |
| 877 | }, |
| 878 | Base: &github.PullRequestBranch{ |
| 879 | Ref: github.Ptr("main"), |
| 880 | }, |
| 881 | Body: github.Ptr("This is a test PR"), |
| 882 | User: &github.User{ |
| 883 | Login: github.Ptr("testuser"), |
| 884 | }, |
| 885 | } |
| 886 | |
| 887 | tests := []struct { |
| 888 | name string |
| 889 | mockedClient *http.Client |
| 890 | requestArgs map[string]any |
| 891 | expectError bool |
| 892 | expectedErrMsg string |
| 893 | }{ |
| 894 | { |
| 895 | name: "successful request", |
| 896 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 897 | PostReposPullsRequestedReviewersByOwnerByRepoByPullNumber: expect(t, expectations{ |
| 898 | path: "/repos/owner/repo/pulls/1/requested_reviewers", |
| 899 | requestBody: map[string]any{ |
| 900 | "reviewers": []any{"copilot-pull-request-reviewer[bot]"}, |
| 901 | }, |
| 902 | }).andThen( |
| 903 | mockResponse(t, http.StatusCreated, mockPR), |
| 904 | ), |
| 905 | }), |
| 906 | requestArgs: map[string]any{ |
| 907 | "owner": "owner", |
| 908 | "repo": "repo", |
| 909 | "pullNumber": float64(1), |
| 910 | }, |
nothing calls this directly
no test coverage detected