Skip to content

test: Simplify the function that skips integration tests - #3752

Merged
gmlewis merged 1 commit into
google:masterfrom
alexandear-org:test/integration-skip-auth
Oct 6, 2025
Merged

test: Simplify the function that skips integration tests#3752
gmlewis merged 1 commit into
google:masterfrom
alexandear-org:test/integration-skip-auth

Conversation

@alexandear

@alexandearalexandear commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

This PR refactors integration tests:

  • Refactor checkAuth function in by passing *testing.T parameter and renaming for clarity.
  • Simplifying client and auth initialization by using sync.OnceValues.
  • Fix TestAPIMeta which fails if run without OAuth token.
Running integration tests locally

TestAPIMeta without token:

go test -tags=integration -count=1 -v -run=TestAPIMeta ./test/integration/...=== RUN TestAPIMeta--- PASS: TestAPIMeta (0.28s)PASSok github.com/google/go-github/v75/test/integration 0.860s

TestAPIMeta with token:

GITHUB_AUTH_TOKEN=ghp_... go test -tags=integration -count=1 -v -run=TestAPIMeta ./test/integration/...=== RUN TestAPIMeta--- PASS: TestAPIMeta (0.28s)PASSok github.com/google/go-github/v75/test/integration 0.860s

All tests without token:

go test -tags=integration -count=1 -v ./test/integration/...=== RUN TestActivity_Starring github_test.go:34: No OAuth token - skipping portions of TestActivity_Starring--- SKIP: TestActivity_Starring (0.30s)=== RUN TestActivity_Watching github_test.go:34: No OAuth token - skipping portions of TestActivity_Watching--- SKIP: TestActivity_Watching (0.20s)=== RUN TestOrganizationAuditLog github_test.go:34: No OAuth token - skipping portions of TestOrganizationAuditLog--- SKIP: TestOrganizationAuditLog (0.00s)=== RUN TestAuthorizationsAppOperations authorizations_test.go:130: Skipping test because the required environment variable (GITHUB_CLIENT_ID) is not present.--- SKIP: TestAuthorizationsAppOperations (0.00s)=== RUN TestIssueEvents--- PASS: TestIssueEvents (1.06s)=== RUN TestEmojis--- PASS: TestEmojis (0.17s)=== RUN TestAPIMeta--- PASS: TestAPIMeta (0.16s)=== RUN TestRateLimits--- PASS: TestRateLimits (0.04s)=== RUN TestPullRequests_ListCommits--- PASS: TestPullRequests_ListCommits (0.26s)=== RUN TestRepositories_CRUD github_test.go:34: No OAuth token - skipping portions of TestRepositories_CRUD--- SKIP: TestRepositories_CRUD (0.00s)=== RUN TestRepositories_BranchesTags--- PASS: TestRepositories_BranchesTags (0.65s)=== RUN TestRepositories_EditBranches github_test.go:34: No OAuth token - skipping portions of TestRepositories_EditBranches--- SKIP: TestRepositories_EditBranches (0.00s)=== RUN TestRepositories_ListByAuthenticatedUser github_test.go:34: No OAuth token - skipping portions of TestRepositories_ListByAuthenticatedUser--- SKIP: TestRepositories_ListByAuthenticatedUser (0.00s)=== RUN TestRepositories_ListByUser--- PASS: TestRepositories_ListByUser (0.65s)=== RUN TestRepositories_DownloadReleaseAsset github_test.go:34: No OAuth token - skipping portions of TestRepositories_DownloadReleaseAsset--- SKIP: TestRepositories_DownloadReleaseAsset (0.00s)=== RUN TestRepositories_Autolinks github_test.go:34: No OAuth token - skipping portions of TestRepositories_Autolinks--- SKIP: TestRepositories_Autolinks (0.00s)=== RUN TestUsers_Get--- PASS: TestUsers_Get (0.34s)=== RUN TestUsers_Update github_test.go:34: No OAuth token - skipping portions of TestUsers_Update--- SKIP: TestUsers_Update (0.00s)=== RUN TestUsers_Emails github_test.go:34: No OAuth token - skipping portions of TestUsers_Emails--- SKIP: TestUsers_Emails (0.00s)=== RUN TestUsers_Keys github_test.go:34: No OAuth token - skipping portions of TestUsers_Keys--- SKIP: TestUsers_Keys (0.16s)PASSok github.com/google/go-github/v75/test/integration 4.347s

@alexandear
alexandearforce-pushed the test/integration-skip-auth branch 3 times, most recently from 556c8f1 to c22f639CompareOctober 3, 2025 22:13
@codecov

codecovBot commented Oct 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.11%. Comparing base (233fe03) to head (9c77662).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #3752 +/- ##
=======================================
Coverage 91.11% 91.11% =======================================
Files 187 187 Lines 16702 16702 =======================================
Hits 15218 15218 Misses 1296 1296 Partials 188 188 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexandear
alexandearforce-pushed the test/integration-skip-auth branch from c22f639 to 9c77662CompareOctober 5, 2025 06:29
@alexandear
alexandear marked this pull request as ready for review October 5, 2025 06:29
Comment on lines +44 to +45
if *meta.VerifiablePasswordAuthentication {
t.Error("APIMeta VerifiablePasswordAuthentication is true")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the story with the complete reversal on this one?
Do we need to add a comment? Or was it just plain broken?

@alexandearalexandearOct 6, 2025

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis I can remove this check at all:

if*meta.VerifiablePasswordAuthentication {
t.Error("APIMeta VerifiablePasswordAuthentication is true")
}

The test will still be valuable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's OK. We can leave it as it will be good-to-know for people who were not aware of the change in 2020.

Thank you, @alexandear!

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @alexandear!
LGTM.
Merging.

@gmlewis
gmlewis merged commit 3f8720b into google:masterOct 6, 2025
7 checks passed
@alexandear
alexandear deleted the test/integration-skip-auth branch October 6, 2025 15:30
jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@alexandear@gmlewis