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

[BUG] Eventually(gexec-session).Should(....) musst not error #88

Closed
danail-branekov opened this issue Jun 5, 2023 · 2 comments · Fixed by #89 or golangci/golangci-lint#3892
Closed
Assignees
Labels
bug Something isn't working

Comments

@danail-branekov
Copy link

danail-branekov commented Jun 5, 2023

Describe the bug
According to gexec.Session docs

In addition, Session satisfies the gbytes.BufferProvider interface and provides the stdout *gbytes.Buffer.  This allows you to replace the first line, above, with:

	Expect(session).Should(gbytes.Say("foo-out"))

However, ginkgolinter reports an error when using a function returning a session as an Eventually argument:

Example:

package my_test

import (
    "os"
    "os/exec"

    . "github.com/onsi/ginkgo/v2"
    . "github.com/onsi/gomega"
    . "github.com/onsi/gomega/gexec"
)

var _ = FDescribe("Foo", func() {
    createSession := func() *Session {
        s, err := Start(exec.Command(os.Args[0]), GinkgoWriter, GinkgoWriter)
        Expect(err).NotTo(HaveOccurred())
        return s
    }

    It("foos", func() {
        Eventually(createSession()).Should(Exit())
    })
})

Produces the following error:

foo_test.go:20:3: ginkgo-linter: use a function call in Eventually. This actually checks nothing, because Eventually receives the function returned value, instead of function itself, and this value is never changed; consider using `Eventually(createSession).Should(Exit())` instead

To Reproduce
Steps to reproduce the behavior:

  1. Run ginkgo linter on the sample above

Expected behavior
The linter should not produce an error

Environment:

  • OS: unrelated
  • Version latest (0.12.0)
@danail-branekov danail-branekov added the bug Something isn't working label Jun 5, 2023
danail-branekov added a commit to cloudfoundry/korifi that referenced this issue Jun 5, 2023
Until issue nunnatsa/ginkgolinter#88 is fixed
and released in golangci-lint
danail-branekov added a commit to cloudfoundry/korifi that referenced this issue Jun 5, 2023
Until issue nunnatsa/ginkgolinter#88 is fixed
and released in golangci-lint
@nunnatsa
Copy link
Owner

nunnatsa commented Jun 6, 2023

Thanks for the report, @danail-branekov

Addressed in #89

@nunnatsa
Copy link
Owner

@danail-branekov, fyi, golangci-lint v1.53.3 just released with a fix to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants