-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_test.go
More file actions
97 lines (89 loc) · 2.23 KB
/
Copy pathcli_test.go
File metadata and controls
97 lines (89 loc) · 2.23 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package lamvms
import (
"testing"
)
func TestParseCLI_Deploy(t *testing.T) {
t.Parallel()
sub, opts, _, err := ParseCLI([]string{"deploy", "--microvm", "testdata/microvm.json"})
if err != nil {
t.Fatal(err)
}
if sub != "deploy" {
t.Errorf("sub = %q, want %q", sub, "deploy")
}
if opts.Microvm != "testdata/microvm.json" {
t.Errorf("Microvm = %q, want %q", opts.Microvm, "testdata/microvm.json")
}
if opts.Deploy == nil {
t.Fatal("Deploy option is nil")
}
if opts.Deploy.DryRun {
t.Error("DryRun should be false by default")
}
}
func TestParseCLI_DeployDryRun(t *testing.T) {
t.Parallel()
sub, opts, _, err := ParseCLI([]string{"deploy", "--dry-run"})
if err != nil {
t.Fatal(err)
}
if sub != "deploy" {
t.Errorf("sub = %q, want %q", sub, "deploy")
}
if opts.Deploy == nil || !opts.Deploy.DryRun {
t.Error("DryRun should be true")
}
}
func TestParseCLI_ExtStr(t *testing.T) {
t.Parallel()
sub, opts, _, err := ParseCLI([]string{"deploy", "-V", "key=value", "-V", "foo=bar"})
if err != nil {
t.Fatal(err)
}
if sub != "deploy" {
t.Errorf("sub = %q, want %q", sub, "deploy")
}
if opts.ExtStr["key"] != "value" {
t.Errorf("ExtStr[key] = %q, want %q", opts.ExtStr["key"], "value")
}
if opts.ExtStr["foo"] != "bar" {
t.Errorf("ExtStr[foo] = %q, want %q", opts.ExtStr["foo"], "bar")
}
}
func TestParseCLI_LogLevel(t *testing.T) {
t.Parallel()
_, opts, _, err := ParseCLI([]string{"deploy", "--log-level", "debug"})
if err != nil {
t.Fatal(err)
}
if opts.LogLevel != "debug" {
t.Errorf("LogLevel = %q, want %q", opts.LogLevel, "debug")
}
}
func TestParseCLI_LogFormat(t *testing.T) {
t.Parallel()
_, opts, _, err := ParseCLI([]string{"deploy", "--log-format", "json"})
if err != nil {
t.Fatal(err)
}
if opts.LogFormat != "json" {
t.Errorf("LogFormat = %q, want %q", opts.LogFormat, "json")
}
}
func TestParseCLI_NoColor(t *testing.T) {
t.Parallel()
_, opts, _, err := ParseCLI([]string{"deploy", "--no-color"})
if err != nil {
t.Fatal(err)
}
if opts.Color {
t.Error("Color should be false with --no-color")
}
}
func TestParseCLI_InvalidCommand(t *testing.T) {
t.Parallel()
_, _, _, err := ParseCLI([]string{"invalid"})
if err == nil {
t.Fatal("expected error for invalid command, got nil")
}
}