feat: add workspace skeleton and server configuration validation

This commit is contained in:
randogoth 2026-10-04 18:55:33 +03:00
commit 6a3a198975
20 changed files with 1891 additions and 0 deletions

64
bin/tests/check.rs Normal file
View file

@ -0,0 +1,64 @@
//! `--check` end to end: a configuration on disk through to the resolved
//! routing, without a renderer registry or a socket.
use std::fs;
const FORMATS: &[&str] = &["gemtext", "html"];
/// Writes a two-site configuration beside a pair of content roots and returns
/// the config path. The config deliberately sits outside both roots.
fn fixture(dir: &std::path::Path) -> std::path::PathBuf {
let one = dir.join("one");
let two = dir.join("two");
fs::create_dir_all(&one).unwrap();
fs::create_dir_all(&two).unwrap();
let text = format!(
r#"
version = 1
[site.one]
root = "{one}"
hosts = ["one.test", "www.one.test"]
[site.two]
root = "{two}"
hosts = ["two.test"]
[listener.web]
protocol = "http"
bind = "0.0.0.0:8080"
formats = ["html"]
default_site = "one"
[listener.feed]
protocol = "nex"
bind = "0.0.0.0:1900"
formats = ["gemtext"]
site = "two"
"#,
one = one.to_str().unwrap(),
two = two.to_str().unwrap(),
);
let path = dir.join("itsybitsy.toml");
fs::write(&path, text).unwrap();
path
}
#[test]
fn checks_a_two_site_configuration() {
let dir = tempfile::tempdir().unwrap();
let path = fixture(dir.path());
itsybitsy::check(&path, FORMATS).unwrap();
}
#[test]
fn an_unprovided_format_names_itself_and_the_file() {
let dir = tempfile::tempdir().unwrap();
let path = fixture(dir.path());
// The registry is empty until a format crate lands, which is exactly the
// "feature switched off" case an operator hits.
let err = itsybitsy::check(&path, &[]).unwrap_err();
let rendered = format!("{err:#}");
assert!(rendered.contains("itsybitsy.toml"), "{rendered}");
assert!(rendered.contains("does not provide"), "{rendered}");
}