use dialtone_common::ap::ActorType; use dialtone_sqlx::control::actor::create_owned::create_credentialed_actor; use dialtone_sqlx::control::user::create::create_user; use dialtone_sqlx::logic::actor::new_actor::NewActor; use dialtone_test_util::{test_action, test_pg}; #[tokio::test] async fn create_credentialed_actor_test() { test_pg::test_pg(move |pool| async move { let acct = "test@example.com"; let action = create_user(&pool, acct, "secretpassword").await; assert!(action.is_ok()); let new_actor = NewActor { preferred_user_name: "test_user", actor_type: ActorType::Person, owner: acct, name: None, summary: None, icon: None, image: None, }; let action = create_credentialed_actor(&pool, new_actor, true, "example.com").await; test_action!(action); }) .await; } #[tokio::test] async fn fail_to_create_credentialed_actor_test() { test_pg::test_pg(move |pool| async move { let real_acct = "real_test@example.com"; let fake_acct = "fake_test@example.com"; let action = create_user(&pool, &real_acct, "secretpassword").await; assert!(action.is_ok()); let new_actor = NewActor { preferred_user_name: "test_user", actor_type: ActorType::Person, owner: fake_acct, name: None, summary: None, icon: None, image: None, }; let action = create_credentialed_actor(&pool, new_actor, true, "example.com").await; assert!(action.is_err()); }) .await; }