Skip to content

Commit

Permalink
Update assertError when expected value is nil (quii#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeirojose authored and quii committed Jan 5, 2020
1 parent 240a0ba commit f49e0f1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,22 @@ func TestAdd(t *testing.T) {
assertDefinition(t, dictionary, word, definition)
})
}
...
func assertError(t *testing.T, got, want error) {
t.Helper()
if got != want {
t.Errorf("got %q want %q", got, want)
}
if got == nil {
if want == nil {
return
}
t.Fatal("expected to get an error.")
}
}
```

For this test, we modified `Add` to return an error, which we are validating against a new error variable, `ErrWordExists`. We also modified the previous test to check for a `nil` error.
For this test, we modified `Add` to return an error, which we are validating against a new error variable, `ErrWordExists`. We also modified the previous test to check for a `nil` error, as well as the `assertError` function.

## Try to run test

Expand Down

0 comments on commit f49e0f1

Please sign in to comment.