use dialtone_common::rest::actors::actor_model::{ActorSystemInfo, ActorVisibility}; use dialtone_sqlx::db::actor::fetch_public::fetch_public_actor_by_id; use dialtone_sqlx::db::actor::update_sysinfo::update_actor_system_info; use dialtone_test_util::create_actor::create_actor_tst_utl; use dialtone_test_util::test_action; use dialtone_test_util::test_constants::{TEST_HOSTNAME, TEST_NOROLEUSER_NAME}; use dialtone_test_util::test_pg::test_pg; #[tokio::test] #[allow(non_snake_case)] async fn GIVEN_visible_actor_WHEN_fetch_actor_by_id_THEN_success() { test_pg(move |pool| async move { let created_actor = create_actor_tst_utl(&pool, TEST_NOROLEUSER_NAME, TEST_HOSTNAME).await; let action = fetch_public_actor_by_id(&pool, &created_actor.owned_actor.ap.id).await; test_action!(action); }) .await; } #[tokio::test] #[allow(non_snake_case)] async fn GIVEN_invisible_actor_WHEN_fetch_actor_by_id_THEN_success() { test_pg(move |pool| async move { // GIVEN let created_actor = create_actor_tst_utl(&pool, TEST_NOROLEUSER_NAME, TEST_HOSTNAME).await; let actor_system_info = ActorSystemInfo { actor_id: created_actor.owned_actor.ap.id.clone(), visibility: ActorVisibility::Invisible, system_data: None, }; let action = update_actor_system_info(&pool, actor_system_info).await; test_action!(action); // WHEN let action = fetch_public_actor_by_id(&pool, &created_actor.owned_actor.ap.id).await; // THEN test_action!(action); }) .await; } #[tokio::test] #[allow(non_snake_case)] async fn GIVEN_banned_actor_WHEN_fetch_actor_by_id_THEN_success() { test_pg(move |pool| async move { // GIVEN let created_actor = create_actor_tst_utl(&pool, TEST_NOROLEUSER_NAME, TEST_HOSTNAME).await; let actor_system_info = ActorSystemInfo { actor_id: created_actor.owned_actor.ap.id.clone(), visibility: ActorVisibility::Banned, system_data: None, }; let action = update_actor_system_info(&pool, actor_system_info).await; test_action!(action); // WHEN let action = fetch_public_actor_by_id(&pool, &created_actor.owned_actor.ap.id).await; // THEN test_action!(action); }) .await; }