(t *testing.T)
| 1105 | } |
| 1106 | |
| 1107 | func Test_GetPullRequestFiles(t *testing.T) { |
| 1108 | // Verify tool definition once |
| 1109 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
| 1110 | tool := serverTool.Tool |
| 1111 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 1112 | |
| 1113 | assert.Equal(t, "pull_request_read", tool.Name) |
| 1114 | assert.NotEmpty(t, tool.Description) |
| 1115 | schema := tool.InputSchema.(*jsonschema.Schema) |
| 1116 | assert.Contains(t, schema.Properties, "method") |
| 1117 | assert.Contains(t, schema.Properties, "owner") |
| 1118 | assert.Contains(t, schema.Properties, "repo") |
| 1119 | assert.Contains(t, schema.Properties, "pullNumber") |
| 1120 | assert.Contains(t, schema.Properties, "page") |
| 1121 | assert.Contains(t, schema.Properties, "perPage") |
| 1122 | assert.ElementsMatch(t, schema.Required, []string{"method", "owner", "repo", "pullNumber"}) |
| 1123 | |
| 1124 | // Setup mock PR files for success case |
| 1125 | mockFiles := []*github.CommitFile{ |
| 1126 | { |
| 1127 | Filename: github.Ptr("file1.go"), |
| 1128 | Status: github.Ptr("modified"), |
| 1129 | Additions: github.Ptr(10), |
| 1130 | Deletions: github.Ptr(5), |
| 1131 | Changes: github.Ptr(15), |
| 1132 | Patch: github.Ptr("@@ -1,5 +1,10 @@"), |
| 1133 | }, |
| 1134 | { |
| 1135 | Filename: github.Ptr("file2.go"), |
| 1136 | Status: github.Ptr("added"), |
| 1137 | Additions: github.Ptr(20), |
| 1138 | Deletions: github.Ptr(0), |
| 1139 | Changes: github.Ptr(20), |
| 1140 | Patch: github.Ptr("@@ -0,0 +1,20 @@"), |
| 1141 | }, |
| 1142 | } |
| 1143 | |
| 1144 | tests := []struct { |
| 1145 | name string |
| 1146 | mockedClient *http.Client |
| 1147 | requestArgs map[string]any |
| 1148 | expectError bool |
| 1149 | expectedFiles []*github.CommitFile |
| 1150 | expectedErrMsg string |
| 1151 | }{ |
| 1152 | { |
| 1153 | name: "successful files fetch", |
| 1154 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 1155 | GetReposPullsFilesByOwnerByRepoByPullNumber: expectQueryParams(t, map[string]string{ |
| 1156 | "page": "1", |
| 1157 | "per_page": "30", |
| 1158 | }).andThen( |
| 1159 | mockResponse(t, http.StatusOK, mockFiles), |
| 1160 | ), |
| 1161 | }), |
| 1162 | requestArgs: map[string]any{ |
| 1163 | "method": "get_files", |
| 1164 | "owner": "owner", |
nothing calls this directly
no test coverage detected