//! Integration smoke test for kei-forge. //! //! Exercises GET / and POST /forge via `tower::ServiceExt::oneshot` on //! the Router — no real socket. With pure-Rust templating, the generator //! is hermetic when pointed at a non-existent crate name: it returns a //! structured `CrateNotFound` without touching the filesystem, so these //! tests can run in any working directory without creating or mutating //! real atoms on disk. //! //! Unit tests for the pure-Rust pipeline (happy path, file-exists refuse, //! crate-not-found, template-missing) live inside `src/generate.rs` and //! its three Constructor-Pattern submodules (placeholders, paths, //! rollback) — they use `tempfile::TempDir` for full hermetic runs. //! //! Run with: `cargo test -p kei-forge` use axum::{ body::{to_bytes, Body}, http::{header, Request, StatusCode}, }; use kei_forge::server; use serde_json::Value; use tower::ServiceExt; const LOCAL_HOST: &str = "127.0.0.1:8747"; fn get(uri: &str) -> Request
{ Request::builder() .uri(uri) .header("host", LOCAL_HOST) .body(Body::empty()) .unwrap() } fn post_json(uri: &str, body: &str) -> Request { Request::builder() .method("POST") .uri(uri) .header("host", LOCAL_HOST) .header("content-type", "application/json") .body(Body::from(body.to_string())) .unwrap() } #[tokio::test] async fn get_root_serves_form() { let app = server::app(); let resp = app.oneshot(get("/")).await.unwrap(); assert_eq!(resp.status(), StatusCode::OK); let body = to_bytes(resp.into_body(), 64 * 1024).await.unwrap(); let html = std::str::from_utf8(&body).unwrap(); assert!(html.contains("kei-forge")); assert!(html.contains("