summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2023-12-12 19:08:32 +0100
committerCyborus <cyborus@cyborus.xyz>2023-12-12 19:08:32 +0100
commitbd6d92f6b6b00d4e570e89098fe4d22b5e59d439 (patch)
treee9e96c9c264cda99dbdf721fbcf21cc64d63ad2c /tests
parentadd admin tests (diff)
downloadforgejo-api-bd6d92f6b6b00d4e570e89098fe4d22b5e59d439.tar.xz
forgejo-api-bd6d92f6b6b00d4e570e89098fe4d22b5e59d439.zip
format
Diffstat (limited to 'tests')
-rw-r--r--tests/ci_test.rs76
1 files changed, 60 insertions, 16 deletions
diff --git a/tests/ci_test.rs b/tests/ci_test.rs
index 91b42eb..e059799 100644
--- a/tests/ci_test.rs
+++ b/tests/ci_test.rs
@@ -249,12 +249,30 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
username: "Pipis".into(),
visibility: "public".into(),
};
- let _ = api.admin_create_user(user_opt).await.wrap_err("failed to create user")?;
+ let _ = api
+ .admin_create_user(user_opt)
+ .await
+ .wrap_err("failed to create user")?;
- let users = api.admin_users(forgejo_api::AdminUserQuery::default()).await.wrap_err("failed to search users")?;
- ensure!(users.iter().find(|u| u.login == "Pipis").is_some(), "could not find new user");
- let users = api.admin_get_emails(forgejo_api::EmailListQuery::default()).await.wrap_err("failed to search emails")?;
- ensure!(users.iter().find(|u| u.email == "user@noreply.example.org").is_some(), "could not find new user");
+ let users = api
+ .admin_users(forgejo_api::AdminUserQuery::default())
+ .await
+ .wrap_err("failed to search users")?;
+ ensure!(
+ users.iter().find(|u| u.login == "Pipis").is_some(),
+ "could not find new user"
+ );
+ let users = api
+ .admin_get_emails(forgejo_api::EmailListQuery::default())
+ .await
+ .wrap_err("failed to search emails")?;
+ ensure!(
+ users
+ .iter()
+ .find(|u| u.email == "user@noreply.example.org")
+ .is_some(),
+ "could not find new user"
+ );
let org_opt = forgejo_api::CreateOrgOption {
description: None,
@@ -265,8 +283,16 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
visibility: forgejo_api::OrgVisibility::Public,
website: None,
};
- let _ = api.admin_create_org("Pipis", org_opt).await.wrap_err("failed to create org")?;
- ensure!(!api.admin_get_orgs(forgejo_api::AdminOrganizationQuery::default()).await?.is_empty(), "org list empty");
+ let _ = api
+ .admin_create_org("Pipis", org_opt)
+ .await
+ .wrap_err("failed to create org")?;
+ ensure!(
+ !api.admin_get_orgs(forgejo_api::AdminOrganizationQuery::default())
+ .await?
+ .is_empty(),
+ "org list empty"
+ );
let key_opt = forgejo_api::CreateKeyOption {
key: "ssh-ed25519 00000000000000000000000000000000000000000000000000000000000000000000 user@noreply.example.org".into(),
@@ -279,12 +305,24 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
let rename_opt = forgejo_api::RenameUserOption {
new_username: "Bepis".into(),
};
- api.admin_rename_user("Pipis", rename_opt).await.wrap_err("failed to rename user")?;
- api.admin_delete_user("Bepis", true).await.wrap_err("failed to delete user")?;
- ensure!(api.admin_delete_user("Ghost", true).await.is_err(), "deleting fake user should fail");
+ api.admin_rename_user("Pipis", rename_opt)
+ .await
+ .wrap_err("failed to rename user")?;
+ api.admin_delete_user("Bepis", true)
+ .await
+ .wrap_err("failed to delete user")?;
+ ensure!(
+ api.admin_delete_user("Ghost", true).await.is_err(),
+ "deleting fake user should fail"
+ );
- let crons = api.admin_get_crons(forgejo_api::CronQuery::default()).await.wrap_err("failed to get crons list")?;
- api.admin_run_cron(&crons.get(0).ok_or_else(|| eyre!("no crons"))?.name).await.wrap_err("failed to run cron")?;
+ let crons = api
+ .admin_get_crons(forgejo_api::CronQuery::default())
+ .await
+ .wrap_err("failed to get crons list")?;
+ api.admin_run_cron(&crons.get(0).ok_or_else(|| eyre!("no crons"))?.name)
+ .await
+ .wrap_err("failed to run cron")?;
let hook_opt = forgejo_api::CreateHookOption {
active: None,
@@ -299,14 +337,20 @@ async fn admin(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
_type: forgejo_api::HookType::Forgejo,
};
// yarr har har me matey this is me hook
- let hook = api.admin_create_hook(hook_opt).await.wrap_err("failed to create hook")?;
+ let hook = api
+ .admin_create_hook(hook_opt)
+ .await
+ .wrap_err("failed to create hook")?;
let edit_hook = forgejo_api::EditHookOption {
active: Some(true),
..Default::default()
};
- api.admin_edit_hook(hook.id, edit_hook).await.wrap_err("failed to edit hook")?;
- api.admin_delete_hook(hook.id).await.wrap_err("failed to delete hook")?;
+ api.admin_edit_hook(hook.id, edit_hook)
+ .await
+ .wrap_err("failed to edit hook")?;
+ api.admin_delete_hook(hook.id)
+ .await
+ .wrap_err("failed to delete hook")?;
Ok(())
}
-