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

Function Test_GetPullRequestStatus

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

Source from the content-addressed store, hash-verified

1441}
1442
1443func Test_GetPullRequestStatus(t *testing.T) {
1444 // Verify tool definition once
1445 serverTool := PullRequestRead(translations.NullTranslationHelper)
1446 tool := serverTool.Tool
1447 require.NoError(t, toolsnaps.Test(tool.Name, tool))
1448
1449 assert.Equal(t, "pull_request_read", tool.Name)
1450 assert.NotEmpty(t, tool.Description)
1451 schema := tool.InputSchema.(*jsonschema.Schema)
1452 assert.Contains(t, schema.Properties, "method")
1453 assert.Contains(t, schema.Properties, "owner")
1454 assert.Contains(t, schema.Properties, "repo")
1455 assert.Contains(t, schema.Properties, "pullNumber")
1456 assert.ElementsMatch(t, schema.Required, []string{"method", "owner", "repo", "pullNumber"})
1457
1458 // Setup mock PR for successful PR fetch
1459 mockPR := &github.PullRequest{
1460 Number: github.Ptr(42),
1461 Title: github.Ptr("Test PR"),
1462 HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42"),
1463 Head: &github.PullRequestBranch{
1464 SHA: github.Ptr("abcd1234"),
1465 Ref: github.Ptr("feature-branch"),
1466 },
1467 }
1468
1469 // Setup mock status for success case
1470 mockStatus := &github.CombinedStatus{
1471 State: github.Ptr("success"),
1472 TotalCount: github.Ptr(3),
1473 Statuses: []*github.RepoStatus{
1474 {
1475 State: github.Ptr("success"),
1476 Context: github.Ptr("continuous-integration/travis-ci"),
1477 Description: github.Ptr("Build succeeded"),
1478 TargetURL: github.Ptr("https://travis-ci.org/owner/repo/builds/123"),
1479 },
1480 {
1481 State: github.Ptr("success"),
1482 Context: github.Ptr("codecov/patch"),
1483 Description: github.Ptr("Coverage increased"),
1484 TargetURL: github.Ptr("https://codecov.io/gh/owner/repo/pull/42"),
1485 },
1486 {
1487 State: github.Ptr("success"),
1488 Context: github.Ptr("lint/golangci-lint"),
1489 Description: github.Ptr("No issues found"),
1490 TargetURL: github.Ptr("https://golangci.com/r/owner/repo/pull/42"),
1491 },
1492 },
1493 }
1494
1495 tests := []struct {
1496 name string
1497 mockedClient *http.Client
1498 requestArgs map[string]any
1499 expectError bool
1500 expectedStatus *github.CombinedStatus

Callers

nothing calls this directly

Calls 14

TestFunction · 0.92
PullRequestReadFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
stubRepoAccessCacheFunction · 0.85
stubFeatureFlagsFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
getTextResultFunction · 0.85
WriteHeaderMethod · 0.80

Tested by

no test coverage detected