Skip to content

Commit a5a7343

Browse files
committed
Add constant and update tests
1 parent 0aa1695 commit a5a7343

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

internal/constants/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ const OverwriteDefaultSystemPathEnvVarName = "ACTIVESTATE_TEST_SYSTEM_PATH"
133133
// TestAutoUpdateEnvVarName is used to test auto updates, when set to true will always attempt to auto update
134134
const TestAutoUpdateEnvVarName = "ACTIVESTATE_TEST_AUTO_UPDATE"
135135

136+
// TestUpdateURLEnvVarName is used to test update urls, when set to a url will override the default update url
137+
const TestUpdateURLEnvVarName = "ACTIVESTATE_TEST_UPDATE_URL"
138+
136139
// ForceUpdateEnvVarName is used to force state tool to update, regardless of whether the update is equal to the current version
137140
const ForceUpdateEnvVarName = "ACTIVESTATE_FORCE_UPDATE"
138141

internal/updater/updater.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func NewUpdateInstaller(cfg Configurable, an analytics.Dispatcher, avUpdate *Ava
128128
func getAPIUpdateURL(cfg Configurable, path string) string {
129129
var apiUpdateURL string
130130

131-
envUrl := os.Getenv("_TEST_UPDATE_URL")
131+
envUrl := os.Getenv(constants.TestUpdateURLEnvVarName)
132132
cfgUrl := cfg.GetString(constants.UpdateEndpointConfig)
133133
switch {
134134
case envUrl != "":

test/integration/update_int_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,8 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateInfoHost() {
320320
cp.ExpectExitCode(0)
321321

322322
cp = ts.SpawnWithOpts(
323-
e2e.OptArgs("update"),
323+
e2e.OptArgs("update", "-v"),
324324
e2e.OptAppendEnv(suite.env(false, false)...),
325-
e2e.OptAppendEnv("VERBOSE=true"),
326325
)
327326
cp.ExpectExitCode(0)
328327

@@ -340,11 +339,11 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateHost_SetBeforeInvocation() {
340339
suite.Assert().Equal(ts.GetConfig(constants.UpdateInfoEndpointConfig), "https://test.example.com/update")
341340

342341
cp := ts.SpawnWithOpts(
343-
e2e.OptArgs("update"),
342+
e2e.OptArgs("update", "-v"),
344343
e2e.OptAppendEnv(suite.env(false, false)...),
345-
e2e.OptAppendEnv("VERBOSE=true"),
346344
)
347345
cp.ExpectExitCode(11) // Expect failure due to DNS resolution of fake host
346+
ts.IgnoreLogErrors()
348347

349348
correctHostCount := 0
350349
incorrectHostCount := 0
@@ -372,22 +371,21 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateHost() {
372371
ts := e2e.New(suite.T(), false)
373372
defer ts.Close()
374373

375-
cp := ts.Spawn("config", "set", constants.UpdateEndpointConfig, "https://example.com/update")
374+
cp := ts.Spawn("config", "set", constants.UpdateEndpointConfig, "https://test.example.com/update")
376375
cp.Expect("Successfully set config key")
377376
cp.ExpectExitCode(0)
378377

379378
cp = ts.SpawnWithOpts(
380-
e2e.OptArgs("update"),
379+
e2e.OptArgs("update", "-v"),
381380
e2e.OptAppendEnv(suite.env(false, false)...),
382-
e2e.OptAppendEnv("VERBOSE=true"),
383381
)
384382
cp.ExpectExitCode(0)
385383

386384
correctHostCount := 0
387385
incorrectHostCount := 0
388386
for _, path := range ts.LogFiles() {
389387
contents := string(fileutils.ReadFileUnsafe(path))
390-
if strings.Contains(contents, "https://example.com/update") {
388+
if strings.Contains(contents, "https://test.example.com/update") {
391389
correctHostCount++
392390
}
393391
if strings.Contains(contents, "https://state-tool.activestate.com/update") {

0 commit comments

Comments
 (0)