Add tests for config error reporting and multi-vhost startup

Test that the server correctly reports missing certificate errors,
rejects invalid hostnames, fails gracefully on port conflicts, and
starts successfully with multiple virtual hosts configured.
This commit is contained in:
Jeena 2026-03-05 20:30:19 +09:00
parent 55fe47b172
commit 7de660dbb6
8 changed files with 94 additions and 392 deletions

View file

@ -57,6 +57,7 @@ key = "{}"
let mut server_process = std::process::Command::new(env!("CARGO_BIN_EXE_pollux"))
.arg("--config")
.arg(&config_path)
.arg("--quiet")
.spawn()
.unwrap();
@ -175,6 +176,7 @@ key = "{}"
let mut server_process = std::process::Command::new(env!("CARGO_BIN_EXE_pollux"))
.arg("--config")
.arg(&config_path)
.arg("--quiet")
.spawn()
.unwrap();
@ -231,6 +233,7 @@ key = "{}"
let output = std::process::Command::new(env!("CARGO_BIN_EXE_pollux"))
.arg("--config")
.arg(&config_path)
.arg("--quiet")
.output()
.unwrap();
@ -246,13 +249,14 @@ fn test_no_hosts_config() {
let config_content = r#"
bind_host = "127.0.0.1"
port = 1965
# No host sections
# No host sections defined
"#;
std::fs::write(&config_path, config_content).unwrap();
let output = std::process::Command::new(env!("CARGO_BIN_EXE_pollux"))
.arg("--config")
.arg(&config_path)
.arg("--quiet")
.output()
.unwrap();
@ -297,6 +301,7 @@ key = "{}"
let output = std::process::Command::new(env!("CARGO_BIN_EXE_pollux"))
.arg("--config")
.arg(&config_path)
.arg("--quiet")
.output()
.unwrap();
@ -331,6 +336,7 @@ port = 1970 # Override global port
let mut server_process = std::process::Command::new(env!("CARGO_BIN_EXE_pollux"))
.arg("--config")
.arg(&config_path)
.arg("--quiet")
.spawn()
.unwrap();
@ -347,6 +353,8 @@ fn test_config_file_not_found() {
let output = std::process::Command::new(env!("CARGO_BIN_EXE_pollux"))
.arg("--config")
.arg("nonexistent.toml")
.arg("--quiet")
.env("RUST_LOG", "error")
.output()
.unwrap();