Skip to content

test: generate per-user email #9322

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

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tests/krate/publish/basics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn new_krate() {
.select(versions_published_by::email)
.first(conn)
.unwrap();
assert_eq!(email, "something@example.com");
assert_eq!(email, "foo@example.com");
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/tests/routes/me/snapshots/all__routes__me__get__me-2.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
source: src/tests/routes/me/get.rs
expression: response.into_json()
expression: response.json()
---
{
"owned_crates": [],
"user": {
"avatar": null,
"email": "something@example.com",
"email": "foo@example.com",
"email_verification_sent": true,
"email_verified": true,
"id": 1,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/routes/me/snapshots/all__routes__me__get__me-3.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/tests/routes/me/get.rs
expression: response.into_json()
expression: response.json()
---
{
"owned_crates": [
Expand All @@ -12,7 +12,7 @@ expression: response.into_json()
],
"user": {
"avatar": null,
"email": "something@example.com",
"email": "foo@example.com",
"email_verification_sent": true,
"email_verified": true,
"id": 1,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async fn test_email_get_and_put() {
let (_app, _anon, user) = TestApp::init().with_user();

let json = user.show_me().await;
assert_eq!(json.user.email.unwrap(), "something@example.com");
assert_eq!(json.user.email.unwrap(), "foo@example.com");

user.update_email("[email protected]").await;

Expand Down
6 changes: 3 additions & 3 deletions src/tests/util/test_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ impl TestApp {
f(&mut self.0.test_database.connect())
}

/// Create a new user with a verified email address in the database and return a mock user
/// session
/// Create a new user with a verified email address in the database
/// (`<username>@example.com``) and return a mock user session.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops

Suggested change
/// (`<username>@example.com``) and return a mock user session.
/// (`<username>@example.com`) and return a mock user session.

///
/// This method updates the database directly
pub fn db_new_user(&self, username: &str) -> MockCookieUser {
use crates_io::schema::emails;
use diesel::prelude::*;

let user = self.db(|conn| {
let email = "something@example.com";
let email = format!("{username}@example.com");

let user = crate::new_user(username)
.create_or_update(None, &self.0.app.emails, conn)
Expand Down