diff --git a/Cargo.lock b/Cargo.lock index 1cf9608..fb515db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,7 +363,7 @@ checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "conformance-tests" version = "0.1.0" -source = "git+https://github.com/fermyon/conformance-tests#8549e0fa0cb7ed41263335cb895eb509c1b61a49" +source = "git+https://github.com/fermyon/conformance-tests#cfee7a519b59f4318d5a19358ec3f2bf1bc23f41" dependencies = [ "anyhow", "flate2", @@ -2530,7 +2530,7 @@ dependencies = [ [[package]] name = "test-environment" version = "0.1.0" -source = "git+https://github.com/fermyon/conformance-tests#8549e0fa0cb7ed41263335cb895eb509c1b61a49" +source = "git+https://github.com/fermyon/conformance-tests#cfee7a519b59f4318d5a19358ec3f2bf1bc23f41" dependencies = [ "anyhow", "fslock", diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index d294020..5cf2db4 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -12,7 +12,7 @@ fn main() -> anyhow::Result<()> { for test in conformance_tests::tests(&tests_dir)? { println!("Test: {}", test.name); let mut manifest = - test_environment::manifest_template::EnvTemplate::from_file(&test.manifest).unwrap(); + test_environment::manifest_template::EnvTemplate::from_file(&test.manifest)?; let env_config = test_environment::TestEnvironmentConfig { create_runtime: Box::new(|_env| { manifest.substitute_value("port", |port| { @@ -24,9 +24,14 @@ fn main() -> anyhow::Result<()> { services_config: test_environment::services::ServicesConfig::none(), }; let mut env = test_environment::TestEnvironment::up(env_config, |_| Ok(())).unwrap(); - if test.config.services.iter().any(|s| s == "http-echo") { - env.runtime_mut() - .set_echo_response(format!("http://localhost:{HTTP_PORT}").as_str())?; + for precondition in &test.config.preconditions { + match precondition { + conformance_tests::config::Precondition::HttpEcho => { + env.runtime_mut() + .set_echo_response(format!("http://localhost:{HTTP_PORT}").as_str())?; + } + conformance_tests::config::Precondition::KeyValueStore(_) => {} + } } for invocation in test.config.invocations { let conformance_tests::config::Invocation::Http(mut invocation) = invocation; diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs index 89f5395..06b7833 100644 --- a/crates/router/src/lib.rs +++ b/crates/router/src/lib.rs @@ -156,8 +156,10 @@ fn calculate_default_headers( base: &str, route_match: &RouteMatch, ) -> anyhow::Result> { + fn convert(s: &str) -> String { + s.to_owned().replace('_', "-").to_ascii_lowercase() + } fn owned(strs: &[&'static str; 2]) -> [String; 2] { - let convert = |s: &str| s.to_owned().replace('_', "-").to_ascii_lowercase(); [convert(strs[0]), convert(strs[1])] } @@ -205,8 +207,11 @@ fn calculate_default_headers( res.push((owned_client_addr, "127.0.0.1:0".to_owned())); for (wild_name, wild_value) in route_match.named_wildcards() { - let wild_header = format!("SPIN_PATH_MATCH_{}", wild_name.to_ascii_uppercase()); - let wild_wagi_header = format!("X_PATH_MATCH_{}", wild_name.to_ascii_uppercase()); + let wild_header = convert(&format!( + "SPIN_PATH_MATCH_{}", + wild_name.to_ascii_uppercase() + )); + let wild_wagi_header = convert(&format!("X_PATH_MATCH_{}", wild_name.to_ascii_uppercase())); res.push(([wild_header, wild_wagi_header], wild_value.clone())); }