-
Notifications
You must be signed in to change notification settings - Fork 0
/
qpm_test.go
93 lines (78 loc) · 1.66 KB
/
qpm_test.go
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
package qpm
import (
"bufio"
"net/url"
"os"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestQPM_ReadAquifer(t *testing.T) {
c := Config{
AquiferPath: "./testdata/",
AquiferRemote: &url.URL{},
Shell: []string{"zsh"},
}
a, err := ReadStratum(c, "foo")
if err != nil {
t.Fatalf("%+v\n", err)
}
want, got := stratum{}, a
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
}
t.Fail()
}
func TestQPM_readStratumFile(t *testing.T) {
t.Parallel()
// Act
got, err := readStratumFile("./testdata/", "foo")
// Assert
if cmp.Diff(nil, err) != "" {
t.Fatalf("%+v\n", err)
}
want := stratumFile{
"install": {{
OS: []string{"linux", "darwin"},
Shell: []string{"zsh", "bash", "sh"},
Dependency: []string{"echo"},
Step: []any{
map[string]any{"name": "Step 1", "run": "echo install for unix"},
"sleep 2",
"echo install for unix",
},
}},
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
}
}
func TestQPM_ReadStratum(t *testing.T) {
c := Config{
AquiferPath: "./testdata/",
}
// Act
got, err := ReadStratum(c, "foo")
// Assert
if cmp.Diff(nil, err) != "" {
t.Fatalf("%+v\n", err)
}
want := stratum{
Name: "foo",
Plan: plan{},
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
}
}
func TestQPM_Execute(t *testing.T) {
c := Config{
AquiferPath: "./testdata/",
AquiferRemote: &url.URL{},
Shell: []string{"zsh"},
}
err := Execute(c, stratum{}, "", bufio.NewWriter(os.Stdout), bufio.NewWriter(os.Stderr))
if err != nil {
t.Fatal(err)
}
t.Fail()
}