Merge pull request #1 from hcengineering/add-sanity-test

add sanity api test
This commit is contained in:
Alexey Aristov
2025-08-29 16:10:44 +02:00
committed by GitHub
22 changed files with 10333 additions and 196 deletions
+2
View File
@@ -1 +1,3 @@
/target
.cargo
.vscode
Generated
+1418 -149
View File
File diff suppressed because it is too large Load Diff
+6 -47
View File
@@ -1,47 +1,6 @@
[package]
name = "hulylake"
version = "0.1.0"
edition = "2024"
rust-version = "1.88.0"
[dependencies]
tokio = { version = "1", features = ["full"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
anyhow = "1.0.99"
config = "0.15.14"
serde = "1.0.219"
actix-web = "4.11.0"
actix-cors = "0.7.1"
refinery = { version = "0.8.16", features = ["tokio-postgres"] }
tokio-postgres = { version = "0.7.13", features = [
"with-uuid-1",
"with-serde_json-1",
] }
bb8 = "0.9.0"
bb8-postgres = { version = "0.9.0", features = ["with-uuid-1"] }
md5 = "0.8.0"
size = { version = "0.5.0", features = ["serde"] }
uuid = { version = "1.18", features = ["v4", "serde"] }
serde_json = "1.0"
hulyrs = { git = "https://github.com/hcengineering/hulyrs.git", features = [
"actix",
] }
secrecy = "0.10.3"
tracing-actix-web = "0.7.19"
aws-config = { version = "1.8.5" }
aws-sdk-s3 = "1.103.0"
reqwest = { version = "0.12.15", default-features = false, features = [
"json",
"rustls-tls",
"stream",
] }
futures-util = "0.3.31"
tokio-stream = "0.1.17"
thiserror = "2.0.16"
bytes = "1.10.1"
ksuid = "0.2.0"
tracing-opentelemetry = "0.31.0"
mime = "0.3.17"
async-stream = "0.3.6"
blake3 = "1.8.2"
[workspace]
resolver = "3"
members = [
"hulylake",
"tests"
]
+3
View File
@@ -0,0 +1,3 @@
/target
.cargo
.vscode
+5243
View File
File diff suppressed because it is too large Load Diff
+47
View File
@@ -0,0 +1,47 @@
[package]
name = "hulylake"
version = "0.1.0"
edition = "2024"
rust-version = "1.88.0"
[dependencies]
tokio = { version = "1", features = ["full"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
anyhow = "1.0.99"
config = "0.15.14"
serde = "1.0.219"
actix-web = "4.11.0"
actix-cors = "0.7.1"
refinery = { version = "0.8.16", features = ["tokio-postgres"] }
tokio-postgres = { version = "0.7.13", features = [
"with-uuid-1",
"with-serde_json-1",
] }
bb8 = "0.9.0"
bb8-postgres = { version = "0.9.0", features = ["with-uuid-1"] }
md5 = "0.8.0"
size = { version = "0.5.0", features = ["serde"] }
uuid = { version = "1.18", features = ["v4", "serde"] }
serde_json = "1.0"
hulyrs = { git = "https://github.com/hcengineering/hulyrs.git", features = [
"actix",
] }
secrecy = "0.10.3"
tracing-actix-web = "0.7.19"
aws-config = { version = "1.8.5" }
aws-sdk-s3 = "1.103.0"
reqwest = { version = "0.12.15", default-features = false, features = [
"json",
"rustls-tls",
"stream",
] }
futures-util = "0.3.31"
tokio-stream = "0.1.17"
thiserror = "2.0.16"
bytes = "1.10.1"
ksuid = "0.2.0"
tracing-opentelemetry = "0.31.0"
mime = "0.3.17"
async-stream = "0.3.6"
blake3 = "1.8.2"
View File
View File
+1
View File
@@ -0,0 +1 @@
/target
+3511
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "tests"
version = "0.1.0"
edition = "2024"
[dependencies]
tanu = "0.8.2"
tokio = { version = "1.47.1", features = ["full"] }
+50
View File
@@ -0,0 +1,50 @@
use crate::config::CONFIG;
use tanu::{check, check_eq, eyre, http::Client};
#[tanu::test]
async fn get_auth_without_token_returns_401() -> eyre::Result<()> {
let http = Client::new();
let res = http
.get(format!("{}/api/huly/example", CONFIG.base_url))
.send()
.await?;
check!(!res.status().is_success());
check_eq!(401, res.status().as_u16());
Ok(())
}
#[tanu::test]
async fn post_auth_without_token_returns_401() -> eyre::Result<()> {
let http = Client::new();
let res = http
.post(format!("{}/api/huly/example", CONFIG.base_url))
.send()
.await?;
check!(!res.status().is_success());
check_eq!(401, res.status().as_u16());
Ok(())
}
#[tanu::test]
async fn put_auth_without_token_returns_401() -> eyre::Result<()> {
let http = Client::new();
let res = http
.put(format!("{}/api/huly/example", CONFIG.base_url))
.send()
.await?;
check!(!res.status().is_success());
check_eq!(401, res.status().as_u16());
Ok(())
}
#[tanu::test]
async fn delete_auth_without_token_returns_401() -> eyre::Result<()> {
let http = Client::new();
let res = http
.delete(format!("{}/api/huly/example", CONFIG.base_url))
.send()
.await?;
check!(!res.status().is_success());
check_eq!(401, res.status().as_u16());
Ok(())
}
+13
View File
@@ -0,0 +1,13 @@
use std::sync::LazyLock;
pub struct Config {
pub base_url: String,
}
pub static CONFIG: LazyLock<Config> = LazyLock::new(|| {
let config = tanu::get_config();
Config {
base_url: config.get_str("base_url").unwrap().to_string(),
}
});
+14
View File
@@ -0,0 +1,14 @@
mod auth;
mod config;
mod sanity;
use tanu::eyre;
#[tanu::main]
#[tokio::main]
async fn main() -> eyre::Result<()> {
let runner = run();
let app = tanu::App::new();
app.run(runner).await?;
Ok(())
}
+14
View File
@@ -0,0 +1,14 @@
use crate::config::CONFIG;
use tanu::{check, check_eq, eyre, http::Client};
#[tanu::test]
async fn status_is_ok() -> eyre::Result<()> {
let http = Client::new();
let res = http
.get(format!("{}/status", CONFIG.base_url))
.send()
.await?;
check!(res.status().is_success());
check_eq!("ok", res.text().await?);
Ok(())
}
+3
View File
@@ -0,0 +1,3 @@
[[projects]]
name = "dev"
base_url = "http://localhost:8096"