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
61
62
63
64
65
66
67
68
69
70
71
|
use std::path::PathBuf;
use alt_controller_image::cli::{Cli, Command};
use clap::Parser;
#[test]
fn parses_plan_with_an_explicit_spec_path() {
let cli = Cli::try_parse_from(["alt-controller-image", "plan", "--spec", "image.toml"])
.expect("plan command parses");
assert!(matches!(
cli.command,
Command::Plan { spec } if spec == PathBuf::from("image.toml")
));
}
#[test]
fn parses_build_with_explicit_workspace_and_output_paths() {
let cli = Cli::try_parse_from([
"alt-controller-image",
"build",
"--spec",
"image.toml",
"--workspace",
"work",
"--output",
"out/image.tar",
])
.expect("build command parses");
assert!(matches!(
cli.command,
Command::Build {
spec,
workspace,
output
} if spec == PathBuf::from("image.toml")
&& workspace == PathBuf::from("work")
&& output == PathBuf::from("out/image.tar")
));
}
#[test]
fn parses_inspect_with_an_explicit_artifact_path() {
let cli = Cli::try_parse_from(["alt-controller-image", "inspect", "--artifact", "out/image.tar"])
.expect("inspect command parses");
assert!(matches!(
cli.command,
Command::Inspect { artifact } if artifact == PathBuf::from("out/image.tar")
));
}
#[test]
fn parses_compare_with_explicit_artifact_paths() {
let cli = Cli::try_parse_from([
"alt-controller-image",
"compare",
"--left",
"legacy.tar",
"--right",
"native.tar",
])
.expect("compare command parses");
assert!(matches!(
cli.command,
Command::Compare { left, right }
if left == PathBuf::from("legacy.tar") && right == PathBuf::from("native.tar")
));
}
|