-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathplatforms_int_test.go
More file actions
174 lines (138 loc) · 4.01 KB
/
platforms_int_test.go
File metadata and controls
174 lines (138 loc) · 4.01 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package integration
import (
"fmt"
"testing"
"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/testhelpers/e2e"
"github.com/ActiveState/cli/internal/testhelpers/suite"
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
)
type PlatformsIntegrationTestSuite struct {
tagsuite.Suite
}
func (suite *PlatformsIntegrationTestSuite) TestPlatforms_searchSimple() {
suite.OnlyRunForTags(tagsuite.Platforms)
ts := e2e.New(suite.T(), false)
defer ts.Close()
ts.PrepareEmptyProject()
cp := ts.Spawn("platforms", "search")
expectations := []string{
"Darwin",
"Linux",
"Windows",
}
for _, expectation := range expectations {
cp.Expect(expectation)
}
cp.ExpectExitCode(0)
}
func (suite *PlatformsIntegrationTestSuite) TestPlatforms_listSimple() {
suite.OnlyRunForTags(tagsuite.Platforms)
ts := e2e.New(suite.T(), false)
defer ts.Close()
ts.PrepareEmptyProject()
cmds := [][]string{
{"platforms"},
{"platforms", "search"},
}
for _, cmd := range cmds {
cp := ts.Spawn(cmd...)
expectations := []string{
"Windows",
"10",
"x86",
"64",
}
for _, expectation := range expectations {
cp.Expect(expectation)
}
cp.ExpectExitCode(0)
}
}
func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemove() {
suite.OnlyRunForTags(tagsuite.Platforms)
ts := e2e.New(suite.T(), false)
defer ts.Close()
ts.PrepareEmptyProject()
platform := "Windows"
version := "10.0.17134.1"
cp := ts.Spawn("config", "set", constants.AsyncRuntimeConfig, "true")
cp.ExpectExitCode(0)
cp = ts.Spawn("platforms", "remove", fmt.Sprintf("%s@%s", platform, version))
cp.ExpectExitCode(0)
cp = ts.Spawn("platforms")
cp.ExpectExitCode(0)
output := cp.Output()
suite.Require().NotContains(output, "Windows", "Windows platform should not be present after removal")
cp = ts.Spawn("platforms", "add", fmt.Sprintf("%s@%s", platform, version))
cp.ExpectExitCode(0)
cp = ts.Spawn("platforms")
expectations := []string{
platform,
version,
"x86",
"64",
}
for _, expectation := range expectations {
cp.Expect(expectation)
}
}
func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemoveLatest() {
suite.OnlyRunForTags(tagsuite.Platforms)
ts := e2e.New(suite.T(), false)
defer ts.Close()
ts.PrepareEmptyProject()
platform := "Windows"
version := "10.0.17134.1"
cp := ts.Spawn("config", "set", constants.AsyncRuntimeConfig, "true")
cp.ExpectExitCode(0)
cp = ts.Spawn("platforms", "remove", fmt.Sprintf("%s@%s", platform, version))
cp.ExpectExitCode(0)
cp = ts.Spawn("platforms")
cp.ExpectExitCode(0)
output := cp.Output()
suite.Require().NotContains(output, "Windows", "Windows platform should not be present after removal")
cp = ts.Spawn("platforms", "add", "windows")
cp.ExpectExitCode(0)
cp = ts.Spawn("platforms")
cp.Expect(platform)
cp.Expect(version)
cp.Expect("x86")
cp.Expect("64")
cp.ExpectExitCode(0)
}
func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addNotFound() {
suite.OnlyRunForTags(tagsuite.Platforms)
ts := e2e.New(suite.T(), false)
defer ts.Close()
ts.PrepareEmptyProject()
// OS name doesn't match
cp := ts.Spawn("platforms", "add", "bunnies")
cp.Expect("Could not find")
cp.ExpectExitCode(1)
// OS version doesn't match
cp = ts.Spawn("platforms", "add", "windows@99.99.99")
cp.Expect("Could not find")
cp.ExpectExitCode(1)
// bitwidth version doesn't match
cp = ts.Spawn("platforms", "add", "windows", "--bit-width=999")
cp.Expect("Could not find")
cp.ExpectExitCode(1)
}
func (suite *PlatformsIntegrationTestSuite) TestJSON() {
suite.OnlyRunForTags(tagsuite.Platforms, tagsuite.JSON)
ts := e2e.New(suite.T(), false)
defer ts.Close()
ts.PrepareEmptyProject()
cp := ts.Spawn("platforms", "-o", "json")
cp.Expect(`[{"name":`)
cp.ExpectExitCode(0)
AssertValidJSON(suite.T(), cp)
cp = ts.Spawn("platforms", "search", "-o", "json")
cp.Expect(`[{"name":`)
cp.ExpectExitCode(0)
AssertValidJSON(suite.T(), cp)
}
func TestPlatformsIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(PlatformsIntegrationTestSuite))
}