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 sentinel errors #5

Open
ahmedalhulaibi opened this issue Jul 10, 2021 · 0 comments
Open

Use sentinel errors #5

ahmedalhulaibi opened this issue Jul 10, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@ahmedalhulaibi
Copy link
Owner

ahmedalhulaibi commented Jul 10, 2021

The errors return should not have newline characters and should be defined as sentinel errors (either as constants or interface) so one can assert against them.

As an example of somewhere where this is being done:

return errors.Errorf("flatfile.parseFlatfileTag: Invalid formatting of named option '%v'\nNamed options should be in the form option=value\nValid options:%v", options, validOptions)


Tests should also assert the specific error returned.

Example of a test not checking the error message returned at all:

flatfile/ffptag_test.go

Lines 60 to 70 in ee3c85f

func TestFfpTagParseMissingParamErr_parseFfpTag(t *testing.T) {
testVal := `flatfile:""`
err := parseFlatfileTag(testVal, &flatfileTag{})
if err == nil {
t.Error("parseFfpTag should return missing parameter error")
}
t.Log(testVal)
t.Log(err)
}

@ahmedalhulaibi ahmedalhulaibi added the enhancement New feature or request label Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant