summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock29
-rw-r--r--Cargo.toml4
-rw-r--r--tests/ci_test.rs31
3 files changed, 59 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 2c23273..0f001b0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -129,6 +129,16 @@ dependencies = [
]
[[package]]
+name = "eyre"
+version = "0.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80f656be11ddf91bd709454d15d5bd896fbaf4cc3314e69349e4d1569f5b46cd"
+dependencies = [
+ "indenter",
+ "once_cell",
+]
+
+[[package]]
name = "fastrand"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -159,6 +169,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
name = "forgejo-api"
version = "0.1.0"
dependencies = [
+ "eyre",
"reqwest",
"serde",
"soft_assert",
@@ -329,6 +340,12 @@ dependencies = [
]
[[package]]
+name = "indenter"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
+
+[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -843,10 +860,22 @@ dependencies = [
"mio",
"pin-project-lite",
"socket2 0.5.5",
+ "tokio-macros",
"windows-sys",
]
[[package]]
+name = "tokio-macros"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "tokio-native-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index d64f32a..56cea66 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,3 +13,7 @@ tokio = { version = "1.29.1", features = ["net"] }
url = { version = "2.4.0", features = ["serde"] }
serde = { version = "1.0.168", features = ["derive"] }
time = { version = "0.3.22", features = ["parsing", "serde", "formatting"] }
+
+[dev-dependencies]
+eyre = "0.6.9"
+tokio = { version = "1.29.1", features = ["net", "rt", "macros"] }
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(())
}