use super::*;
use std::fs;
use tempfile::TempDir;
#[tokio::test]
async fn build_populates_the_output_dir_without_starting_a_server() {
let assets = TempDir::new().unwrap();
let out = TempDir::new().unwrap();
fs::write(assets.path().join("index.html"), "<html>hi</html>").unwrap();
let server = Server::new(out.path())
.unwrap()
.with_asset_folder(assets.path())
.unwrap();
server.build().await.unwrap();
assert_eq!(
fs::read_to_string(out.path().join("index.html")).unwrap(),
"<html>hi</html>",
"build() must populate the output dir synchronously, no server needed"
);
}
#[tokio::test]
async fn build_with_no_pipeline_configured_is_a_harmless_no_op() {
let out = TempDir::new().unwrap();
let server = Server::new(out.path()).unwrap();
server
.build()
.await
.expect("build() with nothing configured must succeed trivially");
}
#[tokio::test]
async fn build_fails_fast_when_a_required_tool_binary_is_missing() {
let src = TempDir::new().unwrap();
let out = TempDir::new().unwrap();
fs::write(src.path().join("a.css"), "body{}").unwrap();
let server = Server::new(out.path())
.unwrap()
.with_source_folder(src.path())
.unwrap()
.with_css_tool(CssTool::TestMissing, CssOptions::new().minify(true));
let result = server.build().await;
assert!(
matches!(result, Err(StaticError::PipelineSetup(_))),
"expected PipelineSetup, got {result:?}"
);
}