Skip to content

Commit e8bd2ef

Browse files
committed
worker/jobs/downloads/update_metadata: Simplify user() test helper fn
There is no need for an "upsert" operation here since we know that the database is in a clean state in our tests. Additionally, this drops the need for the `Emails` implementation, since all we want is a user in the database, but without any email address confirmation emails being sent out.
1 parent c54f44e commit e8bd2ef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/worker/jobs/downloads/update_metadata.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,15 @@ fn batch_update(batch_size: i64, conn: &mut impl Conn) -> QueryResult<i64> {
105105
#[cfg(test)]
106106
mod tests {
107107
use super::*;
108-
use crate::email::Emails;
109108
use crate::models::{Crate, NewCrate, NewUser, NewVersion, User, Version};
110-
use crate::schema::{crate_downloads, crates, versions};
109+
use crate::schema::{crate_downloads, crates, users, versions};
111110
use crate::test_util::test_db_connection;
112111

113112
fn user(conn: &mut impl Conn) -> User {
114-
NewUser::new(2, "login", None, None, "access_token")
115-
.create_or_update(None, &Emails::new_in_memory(), conn)
113+
let user = NewUser::new(2, "login", None, None, "access_token");
114+
diesel::insert_into(users::table)
115+
.values(user)
116+
.get_result(conn)
116117
.unwrap()
117118
}
118119

0 commit comments

Comments
 (0)