-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add test to chat example #3278
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
base: main
Are you sure you want to change the base?
Add test to chat example #3278
Conversation
darth-raijin
left a comment
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.
Hey! Minor ideas for lifting the quality of the test
| username.clear(); | ||
| check_username(&app_state, &mut username, name); | ||
|
|
||
| assert_eq!(username, ""); |
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.
The assertion could be simplified by doing the following
| assert_eq!(username, ""); | |
| assert!(username.is_empty()); |
| use super::*; | ||
|
|
||
| #[tokio::test] | ||
| async fn test_check_username() { |
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.
I think it would be cool if the test reflected the behavior you're asserting in the test, maybe something like:
check_username_registers_unique_usernames
| assert_eq!(username, name); | ||
|
|
||
| username.clear(); | ||
| check_username(&app_state, &mut username, name); |
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.
You could also assert on app_state.user_set again, to ensure the HashSet was not changed
Refs #3263.