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

make func TestSearch.unknown_word check for nil #617

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

1Mark
Copy link
Contributor

@1Mark 1Mark commented Oct 30, 2022

otherwise the refactor contains a regression

Otherwise, there is a regression during refactoring.
@1Mark 1Mark changed the title assertError should ensure that got isn't nil make func TestSearch.unknown_word check for nil Oct 30, 2022
@1Mark
Copy link
Contributor Author

1Mark commented Oct 30, 2022

Alternatively, this logic could be added to the assertErrors function
I.e it could be like

func assertError(t testing.TB, got, want error) {
	t.Helper()
	if want != nil && got == nil {
		t.Fatal("expected to get an error")
	}
	if got != want {
		t.Errorf("got error %q want %q", got, want)
	}
}

However, it will mean that a rewrite will be required for other sections of maps.md (such as here https://quii.gitbook.io/learn-go-with-tests/go-fundamentals/maps#write-the-minimal-amount-of-code-for-the-test-to-run-and-check-the-output-2)

(adding screenshot since I can't get a permalink from the site).

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.

None yet

1 participant