]> Untitled Git - lemmy.git/commitdiff
Fixing some tests
authorDessalines <tyhou13@gmx.com>
Thu, 11 Mar 2021 16:41:04 +0000 (11:41 -0500)
committerDessalines <tyhou13@gmx.com>
Thu, 11 Mar 2021 16:41:04 +0000 (11:41 -0500)
crates/db_queries/src/source/password_reset_request.rs
crates/db_views/src/comment_view.rs
scripts/clear_db.sh [new file with mode: 0755]
scripts/restore_db.sh [moved from restore_db.sh with 100% similarity]

index 96fd06477031a83dc89339d695586609f6891632..dd00e6ff32d107e0b713c8a79245659039ab912a 100644 (file)
@@ -77,7 +77,11 @@ mod tests {
     source::password_reset_request::PasswordResetRequest_,
     Crud,
   };
-  use lemmy_db_schema::source::{password_reset_request::PasswordResetRequest, person::*};
+  use lemmy_db_schema::source::{
+    local_user::{LocalUser, LocalUserForm},
+    password_reset_request::PasswordResetRequest,
+    person::*,
+  };
   use serial_test::serial;
 
   #[test]
@@ -106,15 +110,32 @@ mod tests {
 
     let inserted_person = Person::create(&conn, &new_person).unwrap();
 
+    let new_local_user = LocalUserForm {
+      person_id: inserted_person.id,
+      password_encrypted: "pass".to_string(),
+      email: None,
+      matrix_user_id: None,
+      admin: None,
+      show_nsfw: None,
+      theme: None,
+      default_sort_type: None,
+      default_listing_type: None,
+      lang: None,
+      show_avatars: None,
+      send_notifications_to_email: None,
+    };
+
+    let inserted_local_user = LocalUser::create(&conn, &new_local_user).unwrap();
+
     let token = "nope";
     let token_encrypted_ = "ca3704aa0b06f5954c79ee837faa152d84d6b2d42838f0637a15eda8337dbdce";
 
     let inserted_password_reset_request =
-      PasswordResetRequest::create_token(&conn, inserted_person.id, token).unwrap();
+      PasswordResetRequest::create_token(&conn, inserted_local_user.id, token).unwrap();
 
     let expected_password_reset_request = PasswordResetRequest {
       id: inserted_password_reset_request.id,
-      local_user_id: inserted_person.id,
+      local_user_id: inserted_local_user.id,
       token_encrypted: token_encrypted_.to_string(),
       published: inserted_password_reset_request.published,
     };
index 49bad6c03efafdb5fa229e6d74784674c5943da3..79c4200365d386e53d3c37ae038b0f6670fc3a65 100644 (file)
@@ -449,7 +449,7 @@ mod tests {
     let conn = establish_unpooled_connection();
 
     let new_person = PersonForm {
-      name: "thommy".into(),
+      name: "timmy".into(),
       preferred_username: None,
       avatar: None,
       banner: None,
diff --git a/scripts/clear_db.sh b/scripts/clear_db.sh
new file mode 100755 (executable)
index 0000000..b62490e
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+psql -U lemmy -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public; DROP SCHEMA utils CASCADE;"
similarity index 100%
rename from restore_db.sh
rename to scripts/restore_db.sh