aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/tests/cli_licenses.rs
blob: 96d5c4e56ee4733eaab2bda01b0a75b227d82823 (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
mod common;

use predicates::str::contains;

#[test]
fn test_licenses_locked() {
    let project = common::copy_fixture_to_temp("with_lock");
    common::mozart_cmd()
        .arg("licenses")
        .arg("--locked")
        .arg("--working-dir")
        .arg(project.path())
        .assert()
        .success()
        .stdout(contains("MIT"));
}

#[test]
fn test_licenses_format_json() {
    let project = common::copy_fixture_to_temp("with_lock");
    let output = common::mozart_cmd()
        .arg("licenses")
        .arg("--format=json")
        .arg("--locked")
        .arg("--working-dir")
        .arg(project.path())
        .assert()
        .success()
        .get_output()
        .stdout
        .clone();

    let stdout = String::from_utf8_lossy(&output);
    serde_json::from_str::<serde_json::Value>(&stdout)
        .expect("licenses --format=json output should be valid JSON");
}

#[test]
fn test_licenses_format_summary() {
    let project = common::copy_fixture_to_temp("with_lock");
    common::mozart_cmd()
        .arg("licenses")
        .arg("--format=summary")
        .arg("--locked")
        .arg("--working-dir")
        .arg(project.path())
        .assert()
        .success()
        .stdout(contains("MIT"));
}