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_show.rs | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 crates/mozart/tests/cli_show.rs (limited to 'crates/mozart/tests/cli_show.rs') diff --git a/crates/mozart/tests/cli_show.rs b/crates/mozart/tests/cli_show.rs new file mode 100644 index 0000000..0ecb588 --- /dev/null +++ b/crates/mozart/tests/cli_show.rs @@ -0,0 +1,65 @@ +mod common; + +use predicates::str::contains; + +#[test] +fn test_show_locked_packages() { + let project = common::copy_fixture_to_temp("with_lock"); + common::mozart_cmd() + .arg("show") + .arg("--locked") + .arg("--working-dir") + .arg(project.path()) + .assert() + .success() + .stdout(contains("psr/log")); +} + +#[test] +fn test_show_self() { + let project = common::copy_fixture_to_temp("with_lock"); + common::mozart_cmd() + .arg("show") + .arg("--self-info") + .arg("--working-dir") + .arg(project.path()) + .assert() + .success() + .stdout(contains("test/locked-project")); +} + +#[test] +fn test_show_name_only() { + let project = common::copy_fixture_to_temp("with_lock"); + common::mozart_cmd() + .arg("show") + .arg("--name-only") + .arg("--locked") + .arg("--working-dir") + .arg(project.path()) + .assert() + .success() + .stdout(contains("psr/log")); +} + +#[test] +fn test_show_format_json() { + let project = common::copy_fixture_to_temp("with_lock"); + let output = common::mozart_cmd() + .arg("show") + .arg("--format=json") + .arg("--locked") + .arg("--working-dir") + .arg(project.path()) + .assert() + .success() + .get_output() + .stdout + .clone(); + + let stdout = String::from_utf8_lossy(&output); + // Output should be parseable JSON + let parsed: serde_json::Value = + serde_json::from_str(&stdout).expect("show --format=json output should be valid JSON"); + assert!(parsed.is_array() || parsed.is_object()); +} -- cgit v1.3.1