(t *testing.T)
| 1441 | } |
| 1442 | |
| 1443 | func 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 |
nothing calls this directly
no test coverage detected