Skip to content

Commit 24ed4f8

Browse files
committed
Ensure target branch is always different from current branch
1 parent e04a657 commit 24ed4f8

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

test/integration/update_int_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ type UpdateIntegrationTestSuite struct {
2525

2626
type matcherFunc func(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
2727

28-
func (suite *UpdateIntegrationTestSuite) env(disableUpdates bool) []string {
29-
targetBranch := "release"
28+
var targetBranch = "release"
29+
30+
func init() {
3031
if constants.BranchName == targetBranch {
3132
targetBranch = "master"
3233
}
34+
}
3335

36+
func (suite *UpdateIntegrationTestSuite) env(disableUpdates bool) []string {
3437
env := []string{
3538
"ACTIVESTATE_CLI_AUTO_UPDATE_TIMEOUT=10",
3639
"ACTIVESTATE_CLI_UPDATE_BRANCH=" + targetBranch,
@@ -184,15 +187,15 @@ func (suite *UpdateIntegrationTestSuite) TestLockedChannel() {
184187
pjfile.Save()
185188

186189
cp := ts.SpawnWithOpts(
187-
e2e.WithArgs("update", "lock", "--set-channel", "beta"),
190+
e2e.WithArgs("update", "lock", "--set-channel", targetBranch),
188191
e2e.AppendEnv(suite.env(false)...),
189192
)
190193

191194
cp.Expect("Version locked at")
192-
cp.Expect("beta@")
195+
cp.Expect(targetBranch + "@")
193196
cp.ExpectExitCode(0)
194197

195-
suite.branchCompare(ts, false, "beta", suite.Equal)
198+
suite.branchCompare(ts, false, targetBranch, suite.Equal)
196199
}
197200

198201
func (suite *UpdateIntegrationTestSuite) TestUpdateLockedConfirmationNegative() {
@@ -308,13 +311,13 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateChannel() {
308311
// Ensure we always use a unique exe for updates
309312
ts.UseDistinctStateExe()
310313

311-
cp := ts.SpawnWithOpts(e2e.WithArgs("update", "--set-channel", "beta"), e2e.AppendEnv(suite.env(false)...))
314+
cp := ts.SpawnWithOpts(e2e.WithArgs("update", "--set-channel", targetBranch), e2e.AppendEnv(suite.env(false)...))
312315
cp.Expect("Updating state tool: Downloading latest version")
313316
cp.Expect("Version updated", 60*time.Second)
314-
cp.Expect("beta@", 60*time.Second)
317+
cp.Expect(targetBranch+"@", 60*time.Second)
315318
cp.ExpectExitCode(0)
316319

317-
suite.branchCompare(ts, false, "beta", suite.Equal)
320+
suite.branchCompare(ts, false, targetBranch, suite.Equal)
318321
}
319322

320323
func (suite *UpdateIntegrationTestSuite) TestUpdateNoPermissions() {

0 commit comments

Comments
 (0)