From e40ae3649d62a933211e81d8ac773fdd86ff1dfb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 20:54:29 +0900 Subject: test(cli): add end-to-end integration tests for CLI commands Add 23 integration tests using assert_cmd and predicates covering about, validate, show, licenses, install, config, init, and dump-autoload commands with shared test helpers and fixture projects. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/tests/cli_validate.rs | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 crates/mozart/tests/cli_validate.rs (limited to 'crates/mozart/tests/cli_validate.rs') diff --git a/crates/mozart/tests/cli_validate.rs b/crates/mozart/tests/cli_validate.rs new file mode 100644 index 0000000..fe3c080 --- /dev/null +++ b/crates/mozart/tests/cli_validate.rs @@ -0,0 +1,60 @@ +mod common; + +#[test] +fn test_validate_valid_project() { + let project = common::copy_fixture_to_temp("minimal"); + common::mozart_cmd() + .arg("validate") + .arg("--working-dir") + .arg(project.path()) + .assert() + .success(); +} + +#[test] +fn test_validate_valid_with_lock() { + let project = common::copy_fixture_to_temp("with_lock"); + common::mozart_cmd() + .arg("validate") + .arg("--working-dir") + .arg(project.path()) + .assert() + .success(); +} + +#[test] +fn test_validate_invalid_json() { + let project = common::copy_fixture_to_temp("invalid_json"); + common::mozart_cmd() + .arg("validate") + .arg("--working-dir") + .arg(project.path()) + .assert() + .code(2); +} + +#[test] +fn test_validate_missing_composer_json() { + let project = tempfile::TempDir::new().unwrap(); + common::mozart_cmd() + .arg("validate") + .arg("--working-dir") + .arg(project.path()) + .assert() + .failure(); +} + +#[test] +fn test_validate_strict_with_warnings() { + // A composer.json without a license generates a warning. + // With --strict, warnings become a non-zero exit code. + let project = + common::setup_temp_project(r#"{"name": "test/no-license", "require": {"php": ">=8.1"}}"#); + common::mozart_cmd() + .arg("validate") + .arg("--strict") + .arg("--working-dir") + .arg(project.path()) + .assert() + .code(1); +} -- cgit v1.3.1