@@ -275,14 +275,14 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateTags() {
275275 }
276276}
277277
278- func (suite * UpdateIntegrationTestSuite ) TestUpdateHost_SetBeforeInvocation () {
278+ func (suite * UpdateIntegrationTestSuite ) TestUpdateInfoHost_SetBeforeInvocation () {
279279 suite .OnlyRunForTags (tagsuite .Update )
280280
281281 ts := e2e .New (suite .T (), false )
282282 defer ts .Close ()
283283
284- ts .SetConfig (constants .UpdateEndpointConfig , "https://test.example.com/update" )
285- suite .Assert ().Equal (ts .GetConfig (constants .UpdateEndpointConfig ), "https://test.example.com/update" )
284+ ts .SetConfig (constants .UpdateInfoEndpointConfig , "https://test.example.com/update" )
285+ suite .Assert ().Equal (ts .GetConfig (constants .UpdateInfoEndpointConfig ), "https://test.example.com/update" )
286286
287287 cp := ts .SpawnWithOpts (
288288 e2e .OptArgs ("--version" ),
@@ -303,6 +303,62 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateHost_SetBeforeInvocation() {
303303 suite .Assert ().Greater (correctHostCount , 0 , "Log file should contain the configured API host 'test.example.com'" )
304304 suite .Assert ().Equal (incorrectHostCount , 0 , "Log file should not contain the default API host 'platform.activestate.com'" )
305305
306+ // Clean up - remove the config setting
307+ cp = ts .Spawn ("config" , "set" , constants .UpdateInfoEndpointConfig , "" )
308+ cp .Expect ("Successfully" )
309+ cp .ExpectExitCode (0 )
310+ }
311+
312+ func (suite * UpdateIntegrationTestSuite ) TestUpdateInfoHost () {
313+ suite .OnlyRunForTags (tagsuite .Update )
314+
315+ ts := e2e .New (suite .T (), false )
316+ defer ts .Close ()
317+
318+ cp := ts .Spawn ("config" , "set" , constants .UpdateInfoEndpointConfig , "https://example.com/update-info" )
319+ cp .Expect ("Successfully set config key" )
320+ cp .ExpectExitCode (0 )
321+
322+ cp = ts .SpawnWithOpts (
323+ e2e .OptArgs ("update" , "-v" ),
324+ e2e .OptAppendEnv (suite .env (false , false )... ),
325+ )
326+ cp .ExpectExitCode (0 )
327+
328+ output := cp .Snapshot ()
329+ suite .Assert ().Contains (output , "Getting update info: https://example.com/update-info/" )
330+ }
331+
332+ func (suite * UpdateIntegrationTestSuite ) TestUpdateHost_SetBeforeInvocation () {
333+ suite .OnlyRunForTags (tagsuite .Update )
334+
335+ ts := e2e .New (suite .T (), false )
336+ defer ts .Close ()
337+
338+ ts .SetConfig (constants .UpdateInfoEndpointConfig , "https://test.example.com/update" )
339+ suite .Assert ().Equal (ts .GetConfig (constants .UpdateInfoEndpointConfig ), "https://test.example.com/update" )
340+
341+ cp := ts .SpawnWithOpts (
342+ e2e .OptArgs ("update" , "-v" ),
343+ e2e .OptAppendEnv (suite .env (false , false )... ),
344+ )
345+ cp .ExpectExitCode (11 ) // Expect failure due to DNS resolution of fake host
346+ ts .IgnoreLogErrors ()
347+
348+ correctHostCount := 0
349+ incorrectHostCount := 0
350+ for _ , path := range ts .LogFiles () {
351+ contents := string (fileutils .ReadFileUnsafe (path ))
352+ if strings .Contains (contents , "https://test.example.com/update" ) {
353+ correctHostCount ++
354+ }
355+ if strings .Contains (contents , "https://state-tool.activestate.com/update" ) {
356+ incorrectHostCount ++
357+ }
358+ }
359+ suite .Assert ().Greater (correctHostCount , 0 , "Log file should contain the configured update endpoint 'test.example.com'" )
360+ suite .Assert ().Equal (incorrectHostCount , 0 , "Log file should not contain the default update endpoint 'state-tool.activestate.com'" )
361+
306362 // Clean up - remove the config setting
307363 cp = ts .Spawn ("config" , "set" , constants .UpdateEndpointConfig , "" )
308364 cp .Expect ("Successfully" )
@@ -315,19 +371,29 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateHost() {
315371 ts := e2e .New (suite .T (), false )
316372 defer ts .Close ()
317373
318- cp := ts .Spawn ("config" , "set" , constants .UpdateEndpointConfig , "https://example.com/update" )
374+ cp := ts .Spawn ("config" , "set" , constants .UpdateEndpointConfig , "https://test. example.com/update" )
319375 cp .Expect ("Successfully set config key" )
320376 cp .ExpectExitCode (0 )
321377
322378 cp = ts .SpawnWithOpts (
323- e2e .OptArgs ("update" ),
379+ e2e .OptArgs ("update" , "-v" ),
324380 e2e .OptAppendEnv (suite .env (false , false )... ),
325- e2e .OptAppendEnv ("VERBOSE=true" ),
326381 )
327382 cp .ExpectExitCode (0 )
328383
329- output := cp .Snapshot ()
330- suite .Assert ().Contains (output , "Getting update info: https://example.com/update/" )
384+ correctHostCount := 0
385+ incorrectHostCount := 0
386+ for _ , path := range ts .LogFiles () {
387+ contents := string (fileutils .ReadFileUnsafe (path ))
388+ if strings .Contains (contents , "https://test.example.com/update" ) {
389+ correctHostCount ++
390+ }
391+ if strings .Contains (contents , "https://state-tool.activestate.com/update" ) {
392+ incorrectHostCount ++
393+ }
394+ }
395+ suite .Assert ().Greater (correctHostCount , 0 , "Log file should contain the configured update endpoint 'example.com'" )
396+ suite .Assert ().Equal (incorrectHostCount , 0 , "Log file should not contain the default update endpoint 'state-tool.activestate.com'" )
331397}
332398
333399func TestUpdateIntegrationTestSuite (t * testing.T ) {
0 commit comments