diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-09-19 01:25:31 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-09-20 23:55:22 -0400 |
| commit | e5f72711c5a17c5db24e209b14f82d426eceb86e (patch) | |
| tree | 04865172284c86549dd08d700c21a29c36f54005 /src/test/fixtures/login.rs | |
| parent | 0079624488af334817f58e30dbc676d3adde8de6 (diff) | |
Write tests.
Diffstat (limited to 'src/test/fixtures/login.rs')
| -rw-r--r-- | src/test/fixtures/login.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test/fixtures/login.rs b/src/test/fixtures/login.rs new file mode 100644 index 0000000..b2a4292 --- /dev/null +++ b/src/test/fixtures/login.rs @@ -0,0 +1,44 @@ +use faker_rand::en_us::internet; +use uuid::Uuid; + +use crate::{ + app::App, + repo::login::{self, Login}, +}; + +pub async fn create_for_login(app: &App) -> (String, String) { + let (name, password) = propose(); + app.logins() + .create(&name, &password) + .await + .expect("should always succeed if the login is actually new"); + + (name, password) +} + +pub async fn create(app: &App) -> Login { + let (name, password) = propose(); + app.logins() + .create(&name, &password) + .await + .expect("should always succeed if the login is actually new") +} + +pub fn fictitious() -> Login { + Login { + id: login::Id::generate(), + name: name(), + } +} + +pub fn propose() -> (String, String) { + (name(), propose_password()) +} + +fn name() -> String { + rand::random::<internet::Username>().to_string() +} + +pub fn propose_password() -> String { + Uuid::new_v4().to_string() +} |
