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

Refactor Gomega assertions #18

Closed
wants to merge 2 commits into from

Conversation

mayankshah1607
Copy link
Contributor

  • Create reusable helper functions in utils package to prevent
    rewriting long Gomega assertions
  • Remove redundant ginkgo.By messages to keep logs clean
  • Add line breaks wherever required

Signed-off-by: Mayank Shah mayankshah1614@gmail.com

- Create reusable helper functions in `utils` package to prevent
rewriting long Gomega assertions

Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
Copy link
Contributor

@Pothulapati Pothulapati left a comment

Choose a reason for hiding this comment

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

LGTM and works well!
:+1 for simplifying the error reporting!

@ihcsim
Copy link

ihcsim commented Aug 20, 2020

I am not convinced that you need this change. In particular, I don't think utils/gomega_helpers.go is maintainable in the long run, as gomega has so many assert functions. Are we going to keep wrapping them, as we introduce new ones? I think the wrappers are making things more complex.

E.g., if I see:

gomega.Expect(err).Should(gomega.BeNil(), fmt.Sprintf("failed to inject: %s", stderr)

I can look up the godoc to see what it does.

With this change:

utils.ExpectNil(err, "`linkerd inject` command failed: %s\n%s", out, stderr)

Now I also need to look up what utils.ExpectNil() does (e.g. what are out and stderr used for).

The simplest is still just if err == nil 😄.

It feels like we picked a test framework, now we are trying to work around it (specifically, its verbosity), instead of with it.

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.

3 participants