MCPcopy Index your code
hub / github.com/github/github-mcp-server / Test_GetPullRequestReviews

Function Test_GetPullRequestReviews

pkg/github/pullrequests_test.go:2239–2442  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2237}
2238
2239func Test_GetPullRequestReviews(t *testing.T) {
2240 // Verify tool definition once
2241 serverTool := PullRequestRead(translations.NullTranslationHelper)
2242 tool := serverTool.Tool
2243 require.NoError(t, toolsnaps.Test(tool.Name, tool))
2244
2245 assert.Equal(t, "pull_request_read", tool.Name)
2246 assert.NotEmpty(t, tool.Description)
2247 schema := tool.InputSchema.(*jsonschema.Schema)
2248 assert.Contains(t, schema.Properties, "method")
2249 assert.Contains(t, schema.Properties, "owner")
2250 assert.Contains(t, schema.Properties, "repo")
2251 assert.Contains(t, schema.Properties, "pullNumber")
2252 assert.ElementsMatch(t, schema.Required, []string{"method", "owner", "repo", "pullNumber"})
2253
2254 // Setup mock PR reviews for success case
2255 mockReviews := []*github.PullRequestReview{
2256 {
2257 ID: github.Ptr(int64(201)),
2258 State: github.Ptr("APPROVED"),
2259 Body: github.Ptr("LGTM"),
2260 HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42#pullrequestreview-201"),
2261 User: &github.User{
2262 Login: github.Ptr("approver"),
2263 },
2264 CommitID: github.Ptr("abcdef123456"),
2265 SubmittedAt: &github.Timestamp{Time: time.Now().Add(-24 * time.Hour)},
2266 },
2267 {
2268 ID: github.Ptr(int64(202)),
2269 State: github.Ptr("CHANGES_REQUESTED"),
2270 Body: github.Ptr("Please address the following issues"),
2271 HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42#pullrequestreview-202"),
2272 User: &github.User{
2273 Login: github.Ptr("reviewer"),
2274 },
2275 CommitID: github.Ptr("abcdef123456"),
2276 SubmittedAt: &github.Timestamp{Time: time.Now().Add(-12 * time.Hour)},
2277 },
2278 }
2279
2280 tests := []struct {
2281 name string
2282 mockedClient *http.Client
2283 gqlHTTPClient *http.Client
2284 requestArgs map[string]any
2285 expectError bool
2286 expectedReviews []*github.PullRequestReview
2287 expectedErrMsg string
2288 lockdownEnabled bool
2289 }{
2290 {
2291 name: "successful reviews fetch",
2292 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
2293 GetReposPullsReviewsByOwnerByRepoByPullNumber: mockResponse(t, http.StatusOK, mockReviews),
2294 }),
2295 requestArgs: map[string]any{
2296 "method": "get_reviews",

Callers

nothing calls this directly

Calls 15

TestFunction · 0.92
PullRequestReadFunction · 0.85
mockResponseFunction · 0.85
expectQueryParamsFunction · 0.85
mustNewGHClientFunction · 0.85
mockRESTPermissionServerFunction · 0.85
stubRepoAccessCacheFunction · 0.85
stubFeatureFlagsFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85

Tested by

no test coverage detected