Skip to content

Commit

Permalink
Merge pull request quii#111 from AlexVPopov/patch-3
Browse files Browse the repository at this point in the history
Replace WordExistsError with ErrWordExists
  • Loading branch information
quii authored Jul 25, 2018
2 parents 7254793 + 3c2cba5 commit 3e20b5a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,14 @@ func TestAdd(t *testing.T) {
dictionary := Dictionary{word: definition}
err := dictionary.Add(word, "new test")

assertError(t, err, WordExistsError)
assertError(t, err, ErrWordExists)
assertDefinition(t, dictionary, word, definition)
})
}
```

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

## Try to run test
Expand All @@ -435,7 +435,7 @@ In `dictionary.go`
```go
var (
ErrNotFound = errors.New("could not find the word you were looking for")
WordExistsError = errors.New("cannot add word because it already exists")
ErrWordExists = errors.New("cannot add word because it already exists")
)

func (d Dictionary) Add(word, definition string) error {
Expand All @@ -462,7 +462,7 @@ func (d Dictionary) Add(word, definition string) error {
case ErrNotFound:
d[word] = definition
case nil:
return WordExistsError
return ErrWordExists
default:
return err

Expand Down

0 comments on commit 3e20b5a

Please sign in to comment.