Files
pruefwerk/compliance-agent/tests/demo_seed.rs
T
sharang fdf22e99c0
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Successful in 3m57s
CI / Deploy Dashboard (push) Successful in 5m28s
CI / Deploy Agent (push) Successful in 7m26s
test: lint test code in CI, and run core's integration tests (#379) (#398)
2026-09-25 11:41:56 +00:00

54 lines
1.6 KiB
Rust

//! Demo-target seeding API (needs Mongo; not part of the CI `--lib` run).
#![allow(clippy::expect_used, clippy::unwrap_used)]
mod common;
use common::TestServer;
#[tokio::test]
async fn lists_the_bundled_demo_targets() {
let server = TestServer::start().await;
let res = server
.client
.get(format!("{}/api/v1/targets/demo-seed", server.base_url))
.send()
.await
.expect("request");
assert_eq!(res.status(), 200);
let body: serde_json::Value = res.json().await.expect("json");
let targets = body["targets"].as_array().expect("targets array");
assert!(!targets.is_empty());
for t in targets {
assert!(t["key"].is_string(), "{t}");
assert_eq!(t["source_only"], serde_json::json!(true), "{t}");
assert!(
t["name"].as_str().expect("name").starts_with("Demo · "),
"{t}"
);
}
}
#[tokio::test]
async fn unknown_target_key_is_a_client_error_and_seeds_nothing() {
let server = TestServer::start().await;
let res = server
.client
.post(format!("{}/api/v1/targets/demo-seed", server.base_url))
.json(&serde_json::json!({ "names": ["not-a-demo-target"] }))
.send()
.await
.expect("request");
assert_eq!(res.status(), 400);
let listed: serde_json::Value = server
.client
.get(format!("{}/api/v1/targets", server.base_url))
.send()
.await
.expect("list")
.json()
.await
.expect("json");
assert_eq!(listed["data"].as_array().map(Vec::len), Some(0));
}