Skip to content

Commit 32e8891

Browse files
authored
tests/util/test_app: Simplify db_new_user() fn (#9666)
For tests we don't need the "upsert" behavior of `create_or_update()` and since we're passing in `None` we don't need the email sending behavior either, so let's simplify this to only insert the user in the database and nothing else :)
1 parent 0065796 commit 32e8891

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/tests/util/test_app.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use crate::config::{
44
};
55
use crate::middleware::cargo_compat::StatusCodeConfig;
66
use crate::models::token::{CrateScope, EndpointScope};
7+
use crate::models::User;
78
use crate::rate_limiter::{LimitedAction, RateLimiterConfig};
9+
use crate::schema::users;
810
use crate::storage::StorageConfig;
911
use crate::team_repo::MockTeamRepo;
1012
use crate::tests::util::chaosproxy::ChaosProxy;
@@ -126,8 +128,9 @@ impl TestApp {
126128
let user = self.db(|conn| {
127129
let email = format!("{username}@example.com");
128130

129-
let user = crate::tests::new_user(username)
130-
.create_or_update(None, &self.0.app.emails, conn)
131+
let user: User = diesel::insert_into(users::table)
132+
.values(crate::tests::new_user(username))
133+
.get_result(conn)
131134
.unwrap();
132135
diesel::insert_into(emails::table)
133136
.values((

0 commit comments

Comments
 (0)