-
Notifications
You must be signed in to change notification settings - Fork 1
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
tests(quotes.go): create unit test #9
Conversation
if quoteList[key] != val { | ||
t.Errorf(`error, expected "%s", got "%s"`, val, quoteList[key]) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is a welcomed addition. My bigger concern is #7 with a few invariants I worry about.
- The "default" search always returns all quotes
- Searches return the expected quotes
- New quotes get added to the end of pre-existing searches
- There was a bug in a previous version that once a search ran until completion it would start returning
""
instead of restarting. Exhausting a quote should just restart the search (with or without a new random order)
@servusdei2018 Are you planning on adding additional tests to this PR? I can merge this now without closing #7 |
Yeah I'll probably try to add some tests for searching in this PR too 👍🏽 |
Okay I now added test coverage for searches, and it should hit all the major points you listed:
|
This all looks good to me, I would say that the addition of tests has highlighted how much we depend on random globals all over the place and that should probably be looked at, though that can be its own PR for whoever feels so inclined. |
This PR adds unit tests for
quotes.go
. The loading and writing of quotes is tested to ensure expected functionality, by mocking an io.Reader and io.Writer.