Skip to content

Commit 941ed5d

Browse files
committed
Add test
1 parent 9c2e2ea commit 941ed5d

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package integration
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/suite"
7+
8+
"github.com/ActiveState/cli/internal/constants"
9+
10+
"github.com/ActiveState/cli/internal/testhelpers/e2e"
11+
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
12+
)
13+
14+
type SoftLimitIntegrationTestSuite struct {
15+
tagsuite.Suite
16+
}
17+
18+
/*
19+
Test several important paths for the soft limit notification to show.
20+
We're not testing all possible paths as it would be too expensive both in terms of testing time as well as maintenance of those tests.
21+
*/
22+
func (suite *SoftLimitIntegrationTestSuite) TestCheckout() {
23+
suite.OnlyRunForTags(tagsuite.SoftLimit)
24+
25+
ts := e2e.New(suite.T(), true)
26+
defer ts.Close()
27+
28+
ts.LoginAsPersistentUser()
29+
30+
cp := ts.SpawnWithOpts(
31+
e2e.WithArgs("checkout", "ActiveState-CLI/small-python", "."),
32+
e2e.AppendEnv(constants.RuntimeUsageOverrideEnvVarName+"=999"),
33+
e2e.AppendEnv(constants.DisableRuntime+"=true"), // We're testing the usage, not the runtime
34+
)
35+
cp.Expect("You've reached your runtime limit")
36+
cp.ExpectExitCode(0)
37+
38+
suite.Run("activate", func() {
39+
cp := ts.SpawnWithOpts(
40+
e2e.WithArgs("activate"),
41+
e2e.AppendEnv(constants.RuntimeUsageOverrideEnvVarName+"=999"),
42+
e2e.AppendEnv(constants.DisableRuntime+"=true"),
43+
)
44+
cp.Expect("You've reached your runtime limit")
45+
cp.Expect("Activated")
46+
cp.WaitForInput()
47+
cp.SendLine("exit 0")
48+
cp.ExpectExitCode(0)
49+
})
50+
51+
suite.Run("shell", func() {
52+
cp := ts.SpawnWithOpts(
53+
e2e.WithArgs("shell"),
54+
e2e.AppendEnv(constants.RuntimeUsageOverrideEnvVarName+"=999"),
55+
e2e.AppendEnv(constants.DisableRuntime+"=true"),
56+
)
57+
cp.Expect("You've reached your runtime limit")
58+
cp.Expect("Activated")
59+
cp.WaitForInput()
60+
cp.SendLine("exit 0")
61+
cp.ExpectExitCode(0)
62+
})
63+
}
64+
65+
func TestSoftLimitIntegrationTestSuite(t *testing.T) {
66+
suite.Run(t, new(SoftLimitIntegrationTestSuite))
67+
}

0 commit comments

Comments
 (0)