-
-
Notifications
You must be signed in to change notification settings - Fork 748
Use UserBuilder in more tests
#14238
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ static ENCRYPTED_TOKEN: LazyLock<Vec<u8>> = LazyLock::new(|| { | |
| /// If you want to test logic that happens as part of signing up or logging in, | ||
| pub struct UserBuilder<'a> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering at what point we would want to pull |
||
| username: &'a str, | ||
| display_name: Option<&'a str>, | ||
| } | ||
|
|
||
| impl<'a> UserBuilder<'a> { | ||
|
|
@@ -30,18 +31,26 @@ impl<'a> UserBuilder<'a> { | |
| pub fn new() -> Self { | ||
| Self { | ||
| username: "octocat", | ||
| display_name: None, | ||
| } | ||
| } | ||
|
|
||
| pub fn with_username(self, username: &'a str) -> Self { | ||
| Self { username } | ||
| Self { username, ..self } | ||
| } | ||
|
|
||
| pub fn with_display_name(self, display_name: &'a str) -> Self { | ||
| Self { | ||
| display_name: Some(display_name), | ||
| ..self | ||
| } | ||
| } | ||
|
|
||
| pub fn build(self) -> User { | ||
| User { | ||
| id: 1, | ||
| gh_login: self.username.into(), | ||
| name: Some("The Octocat".into()), | ||
| name: self.display_name.map(ToString::to_string), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is technically a change in behaviour, but since the CI is green I'm assuming we weren't relying on it anywhere. |
||
| gh_id: 123, | ||
| gh_avatar: None, | ||
| gh_encrypted_token: vec![], | ||
|
|
@@ -59,6 +68,7 @@ impl<'a> UserBuilder<'a> { | |
| .gh_id(next_gh_id()) | ||
| .gh_login(self.username) | ||
| .username(self.username) | ||
| .maybe_name(self.display_name) | ||
| .gh_encrypted_token(&ENCRYPTED_TOKEN) | ||
| .build() | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
hmm... I'm feeling a bit uneasy about adding this to the database crate since it pulls in:
that creates quite a spaghetti in the dependency tree 😅
View changes since the review
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.
ok 🤷🏻♀️ i put it back the way it was!