From 9528ef808cdff30a2f91b129a3f72381101e3af9 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 24 Feb 2026 00:24:08 +0000 Subject: [PATCH] story-kit: merge 127_story_test_coverage_http_mod_rs --- server/src/http/mod.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/server/src/http/mod.rs b/server/src/http/mod.rs index b4ac54b..b37d946 100644 --- a/server/src/http/mod.rs +++ b/server/src/http/mod.rs @@ -150,4 +150,37 @@ mod tests { remove_port_file(&path); assert!(!path.exists()); } + + #[test] + fn write_port_file_returns_none_on_nonexistent_dir() { + let bad = std::path::Path::new("/this_dir_does_not_exist_storykit_test_xyz"); + assert!(write_port_file(bad, 1234).is_none()); + } + + #[test] + fn remove_port_file_does_not_panic_for_missing_file() { + let path = std::path::Path::new("/tmp/nonexistent_storykit_port_test_xyz_999"); + remove_port_file(path); + } + + #[test] + fn resolve_port_returns_a_valid_port() { + // Exercises the resolve_port code path (reads STORYKIT_PORT env var or defaults). + let port = resolve_port(); + assert!(port > 0); + } + + #[test] + fn build_openapi_service_constructs_without_panic() { + let tmp = tempfile::tempdir().unwrap(); + let ctx = Arc::new(context::AppContext::new_test(tmp.path().to_path_buf())); + let (_api_service, _docs_service) = build_openapi_service(ctx); + } + + #[test] + fn build_routes_constructs_without_panic() { + let tmp = tempfile::tempdir().unwrap(); + let ctx = context::AppContext::new_test(tmp.path().to_path_buf()); + let _endpoint = build_routes(ctx); + } }