aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/tests/cli_validate.rs
blob: fe3c080ccd87d7605f28d337bf1246bd45beeaed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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);
}