use dialtone_common::rest::actors::actor_model::UpdateOwnerActorAp; use dialtone_sqlx::db::actor::fetch_owned::fetch_owned_actor_by_id; use dialtone_sqlx::db::actor::update_ap::{update_actor_ap, update_actor_ap_by_owner}; use dialtone_test_util::create_actor::create_actor_tst_utl; use dialtone_test_util::test_action; use dialtone_test_util::test_pg::test_pg; #[tokio::test] async fn update_actor_ap_test() { test_pg(move |pool| async move { let created_actor = create_actor_tst_utl(&pool, "testymctestfase", "example.com").await; let actor_id = created_actor.owned_actor.ap.id; let action = fetch_owned_actor_by_id(&pool, &actor_id).await; test_action!(action); assert!(action.unwrap().unwrap().ap.name.is_none()); let update = UpdateOwnerActorAp { name: Some("foo".to_string()), summary: None, icon: None, image: None, }; let action = update_actor_ap(&pool, update, &actor_id).await; test_action!(action); let action = fetch_owned_actor_by_id(&pool, &actor_id).await; test_action!(action); let name = action.unwrap().unwrap().ap.name; assert!(name.is_some()); assert_eq!(name.unwrap(), "foo"); }) .await; } #[tokio::test] async fn update_actor_ap_by_owner_test() { test_pg(move |pool| async move { let created_actor = create_actor_tst_utl(&pool, "testymctestfase", "example.com").await; let actor_id = created_actor.owned_actor.ap.id; let owner = created_actor.creating_user_acct; let action = fetch_owned_actor_by_id(&pool, &actor_id).await; test_action!(action); assert!(action.unwrap().unwrap().ap.name.is_none()); let update = UpdateOwnerActorAp { name: Some("foo".to_string()), summary: None, icon: None, image: None, }; let action = update_actor_ap_by_owner(&pool, update, &actor_id, &owner).await; test_action!(action); let action = fetch_owned_actor_by_id(&pool, &actor_id).await; test_action!(action); let name = action.unwrap().unwrap().ap.name; assert!(name.is_some()); assert_eq!(name.unwrap(), "foo"); }) .await; }