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

Check for the exact error class in all tests #71

Closed
zimmski opened this issue Dec 5, 2016 · 1 comment
Closed

Check for the exact error class in all tests #71

zimmski opened this issue Dec 5, 2016 · 1 comment

Comments

@zimmski
Copy link
Collaborator

zimmski commented Dec 5, 2016

Checks like the following must be refactored

_, err = dmp.DiffFromDelta("", "+%c3%xy")
if err == nil {
	assert.Fail(t, "expected Invalid URL escape.")
}

The problem is that we only check that the error is not nil, but we do not check for the error class. This means that any error lets the test pass even though it is possible that it was the wrong error.

One way to test for the error class is to simply check if assert.Contains if a part of the error string can be found. Another one is to add special error types, and another one is to use one of many encapsulating error packages.

@maksimov
Copy link
Contributor

maksimov commented Dec 5, 2016

Found this a little odd when I was extending the tests. I might have a swing at that.

maksimov added a commit to maksimov/go-diff that referenced this issue Dec 5, 2016
maksimov added a commit to maksimov/go-diff that referenced this issue Dec 24, 2016
Code-review changes, update to an incorrectly worded error message
maksimov added a commit to maksimov/go-diff that referenced this issue Apr 3, 2017
Code-review changes, update to an incorrectly worded error message
@zimmski zimmski closed this as completed in ad02bdd Apr 9, 2017
zimmski added a commit that referenced this issue Apr 9, 2017
Refactored error checking tests. Fixes #71
maksimov added a commit to maksimov/go-diff that referenced this issue Apr 9, 2017
Code-review changes, update to an incorrectly worded error message
maksimov added a commit to maksimov/go-diff that referenced this issue Apr 9, 2017
Code-review changes, update to an incorrectly worded error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants