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

use suite testing in a good way #2

Open
marcelloh opened this issue Apr 6, 2024 · 0 comments
Open

use suite testing in a good way #2

marcelloh opened this issue Apr 6, 2024 · 0 comments

Comments

@marcelloh
Copy link

This is what you have:

func (suite *facesTestSuite) TestShouldNotReveal() {
	var (
		actual = &user{
			Email:           "foo&bar.com",
			Password:        "123",
			unexportedField: "Foo",
		}
		expected = actual
	)

	Reveal(actual, "private")

	assert.Equal(suite.T(), expected, actual)
}

and this is how it should be done:

func (suite *facesTestSuite) TestShouldNotReveal() {
	var (
		actual = &user{
			Email:           "foo&bar.com",
			Password:        "123",
			unexportedField: "Foo",
		}
		expected = actual
	)

	Reveal(actual, "private")

	suite.assert.Equal(expected, actual)
}

and... why fill the vars like that (with the var() around them?)
you have:

	var (
		actual = &user{
			Email:           "foo&bar.com",
			Password:        "123",
			unexportedField: "Foo",
		}
		expected = actual
	)

but you can do:

	actual := &user{
		Email:           "foo&bar.com",
		Password:        "123",
		unexportedField: "Foo",
	}
	expected := actual

Less lines and less indentations, which makes it easier to read

Just my 2 cents....

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

No branches or pull requests

1 participant