Skip to content

Conversation

nunnatsa
Copy link
Owner

Description

ginkgolinter fails to recognized ginkgo.SpecContext as a valid context in Eventually, and so wrongly identify it as the actual value, instead of the following function parameter.

This PR fixes the issue and now this scenarion works

It("should work", func(ctx SpecContext) {
	Eventually(func() error {
		return fmt.Errorf("foo")
	}).WithContext(ctx).Should(MatchError("foo"))
}, SpecTimeout(time.Second))

Fixes #190

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Refactoring

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added test case and related test data
  • Update the functional test

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I ran make goimports
  • I ran golangci-lint

ginkgolinter fails to recognized ginkgo.SpecContext as a valid context in
Eventually, and so wrongly identify it as the actual value, instead of
the following function parameter.

This PR fixes the issue and now this scenarion works

```go
It("should work", func(ctx SpecContext) {
	Eventually(func() error {
		return fmt.Errorf("foo")
	}).WithContext(ctx).Should(MatchError("foo"))
}, SpecTimeout(time.Second))
```
Copy link

Pull Request Test Coverage Report for Build 13390718887

Details

  • 12 of 12 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.09%) to 77.656%

Totals Coverage Status
Change from base Build 13336914408: 0.09%
Covered Lines: 2200
Relevant Lines: 2833

💛 - Coveralls

@nunnatsa nunnatsa merged commit 1b633dc into main Feb 18, 2025
1 check passed
@nunnatsa nunnatsa deleted the fix-190 branch February 18, 2025 12:41
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.

[BUG] False Positive for the MatchError matcher used to assert a non error type in Eventually cases with SpecContext arguments
1 participant