@@ -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,63 @@ 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" ),
324+ e2e .OptAppendEnv (suite .env (false , false )... ),
325+ e2e .OptAppendEnv ("VERBOSE=true" ),
326+ )
327+ cp .ExpectExitCode (0 )
328+
329+ output := cp .Snapshot ()
330+ suite .Assert ().Contains (output , "Getting update info: https://example.com/update-info/" )
331+ }
332+
333+ func (suite * UpdateIntegrationTestSuite ) TestUpdateHost_SetBeforeInvocation () {
334+ suite .OnlyRunForTags (tagsuite .Update )
335+
336+ ts := e2e .New (suite .T (), false )
337+ defer ts .Close ()
338+
339+ ts .SetConfig (constants .UpdateInfoEndpointConfig , "https://test.example.com/update" )
340+ suite .Assert ().Equal (ts .GetConfig (constants .UpdateInfoEndpointConfig ), "https://test.example.com/update" )
341+
342+ cp := ts .SpawnWithOpts (
343+ e2e .OptArgs ("update" ),
344+ e2e .OptAppendEnv (suite .env (false , false )... ),
345+ e2e .OptAppendEnv ("VERBOSE=true" ),
346+ )
347+ cp .ExpectExitCode (11 ) // Expect failure due to DNS resolution of fake host
348+
349+ correctHostCount := 0
350+ incorrectHostCount := 0
351+ for _ , path := range ts .LogFiles () {
352+ contents := string (fileutils .ReadFileUnsafe (path ))
353+ if strings .Contains (contents , "https://test.example.com/update" ) {
354+ correctHostCount ++
355+ }
356+ if strings .Contains (contents , "https://state-tool.activestate.com/update" ) {
357+ incorrectHostCount ++
358+ }
359+ }
360+ suite .Assert ().Greater (correctHostCount , 0 , "Log file should contain the configured update endpoint 'test.example.com'" )
361+ suite .Assert ().Equal (incorrectHostCount , 0 , "Log file should not contain the default update endpoint 'state-tool.activestate.com'" )
362+
306363 // Clean up - remove the config setting
307364 cp = ts .Spawn ("config" , "set" , constants .UpdateEndpointConfig , "" )
308365 cp .Expect ("Successfully" )
@@ -326,8 +383,19 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateHost() {
326383 )
327384 cp .ExpectExitCode (0 )
328385
329- output := cp .Snapshot ()
330- suite .Assert ().Contains (output , "Getting update info: https://example.com/update/" )
386+ correctHostCount := 0
387+ incorrectHostCount := 0
388+ for _ , path := range ts .LogFiles () {
389+ contents := string (fileutils .ReadFileUnsafe (path ))
390+ if strings .Contains (contents , "https://example.com/update" ) {
391+ correctHostCount ++
392+ }
393+ if strings .Contains (contents , "https://state-tool.activestate.com/update" ) {
394+ incorrectHostCount ++
395+ }
396+ }
397+ suite .Assert ().Greater (correctHostCount , 0 , "Log file should contain the configured update endpoint 'example.com'" )
398+ suite .Assert ().Equal (incorrectHostCount , 0 , "Log file should not contain the default update endpoint 'state-tool.activestate.com'" )
331399}
332400
333401func TestUpdateIntegrationTestSuite (t * testing.T ) {
0 commit comments