diff options
author | Cyborus <cyborus@cyborus.xyz> | 2023-11-29 21:18:55 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2023-11-30 01:09:15 +0100 |
commit | cea10e2fcafbbae4d16f081524862240d41cc949 (patch) | |
tree | 20503f326b3b58637e69a03c8c946b9be791e5c4 /tests | |
parent | add ci pipeline (diff) | |
download | forgejo-api-cea10e2fcafbbae4d16f081524862240d41cc949.tar.xz forgejo-api-cea10e2fcafbbae4d16f081524862240d41cc949.zip |
add testing boilerplate
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ci_test.rs | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/tests/ci_test.rs b/tests/ci_test.rs index ffa6392..11d7e64 100644 --- a/tests/ci_test.rs +++ b/tests/ci_test.rs @@ -1,6 +1,27 @@ -#[test] -fn ci() { - let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL").unwrap()).unwrap(); - let token = std::env::var("FORGEJO_API_CI_TOKEN").unwrap(); - let api = forgejo_api::Forgejo::new(&token, url).unwrap(); +use forgejo_api::{Forgejo, ForgejoError}; + +#[tokio::test] +async fn ci() -> eyre::Result<()> { + let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL")?)?; + let token = std::env::var("FORGEJO_API_CI_TOKEN")?; + let api = Forgejo::new(&token, url)?; + + let mut results = Vec::new(); + + results.push(user(&api).await.map_err(|e| eyre::eyre!("user error: {e}"))); + + let mut errors = 0; + for res in results.into_iter().filter_map(Result::err) { + errors += 1; + println!("{res}"); + } + if errors > 0 { + eyre::bail!("test failed"); + } + + Ok(()) +} + +async fn user(api: &forgejo_api::Forgejo) -> Result<(), ForgejoError> { + Ok(()) } |