Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky test TestCommitStatusTargetURL #39

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Conversation

hnnsgstfssn
Copy link

The test added in [1] uses environment variables in a parallel test which causes it to be flaky and sometimes fail as is described in [2].

To fix the flaky test, the environment variable is pulled out and read in the caller of the function under test, so that it can be tested without reading the global environment variable.

[1] a43d3d1
[2] https://pkg.go.dev/testing#T.Setenv

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change
  • Refactor
  • Documentation
  • Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

The test added in [1] uses environment variables in a parallel test
which causes it to be flaky and sometimes fail as is described in [2].

To fix the flaky test, the environment variable is pulled out and read
in the caller of the function under test, so that it can be tested
without reading the global environment variable.

[1] a43d3d1
[2] https://pkg.go.dev/testing#T.Setenv
@hnnsgstfssn
Copy link
Author

Verified with

for i in $(seq 20); do go test ./... -count=1 -run=TestCommit; done

@hnnsgstfssn hnnsgstfssn merged commit e695d4c into main Oct 29, 2024
5 checks passed
Sign up for free to 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