From 06b5f60fd066ec0e1e41c5f85973b323d429b464 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 21 Jun 2026 03:42:21 +0900 Subject: test(factory): port FactoryTest getComposerFile env paths verified. The default-values case mocks IO/Config (unportable); the unset-env case is order-dependent without the deferred tearDown, so both are ignored. setUp/tearDown not ported. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/tests/factory_test.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'crates') diff --git a/crates/shirabe/tests/factory_test.rs b/crates/shirabe/tests/factory_test.rs index a7ad372..687e5ab 100644 --- a/crates/shirabe/tests/factory_test.rs +++ b/crates/shirabe/tests/factory_test.rs @@ -1 +1,36 @@ //! ref: composer/tests/Composer/Test/FactoryTest.php + +use shirabe::factory::Factory; +use shirabe::util::platform::Platform; + +#[test] +#[ignore = "mocks an IOInterface with a writeError expectation and a Config returning disable-tls=true; mocking is not available"] +fn test_default_values_are_as_expected() { + todo!() +} + +#[test] +#[ignore = "depends on COMPOSER being unset, but sibling tests set it and the tearDown that clears it is not ported"] +fn test_get_composer_json_path() { + assert_eq!("./composer.json", Factory::get_composer_file().unwrap()); +} + +#[test] +fn test_get_composer_json_path_fails_if_dir() { + let dir = env!("CARGO_MANIFEST_DIR"); + Platform::put_env("COMPOSER", dir); + let err = Factory::get_composer_file().unwrap_err(); + assert_eq!( + format!( + "The COMPOSER environment variable is set to {} which is a directory, this variable should point to a composer.json or be left unset.", + dir + ), + err.to_string() + ); +} + +#[test] +fn test_get_composer_json_path_from_env() { + Platform::put_env("COMPOSER", " foo.json "); + assert_eq!("foo.json", Factory::get_composer_file().unwrap()); +} -- cgit v1.3.1