@@ -281,6 +281,94 @@ func (suite *InstallScriptsIntegrationTestSuite) assertCorrectVersion(ts *e2e.Se
281281 }
282282}
283283
284+ func (suite * InstallScriptsIntegrationTestSuite ) TestInstall_ConfigSet () {
285+ suite .OnlyRunForTags (tagsuite .InstallScripts )
286+ ts := e2e .New (suite .T (), false )
287+ defer ts .Close ()
288+
289+ baseUrl := "https://state-tool.s3.amazonaws.com/update/state/"
290+ scriptBaseName := "install."
291+ if runtime .GOOS != "windows" {
292+ scriptBaseName += "sh"
293+ } else {
294+ scriptBaseName += "ps1"
295+ }
296+ scriptUrl := baseUrl + constants .ChannelName + "/" + scriptBaseName
297+
298+ b , err := httputil .GetDirect (scriptUrl )
299+ suite .Require ().NoError (err )
300+ script := filepath .Join (ts .Dirs .Work , scriptBaseName )
301+ suite .Require ().NoError (fileutils .WriteFile (script , b ))
302+
303+ installDir := filepath .Join (ts .Dirs .Work , "install" )
304+ args := []string {script }
305+ args = append (args , "-t" , installDir )
306+ args = append (args , "-n" ) // non-interactive
307+ args = append (args , "-b" , constants .ChannelName )
308+
309+ args = append (args , "--config-set" , "analytics.enabled=false" )
310+ args = append (args , "--config-set" , "output.format json" ) // space-separated format
311+ args = append (args , "--config-set" , "test.key1=value1,test.key2=value2" ) // comma-separated format
312+
313+ appInstallDir := filepath .Join (ts .Dirs .Work , "app" )
314+ suite .NoError (fileutils .Mkdir (appInstallDir ))
315+
316+ cmd := "bash"
317+ opts := []e2e.SpawnOptSetter {
318+ e2e .OptArgs (args ... ),
319+ e2e .OptAppendEnv (constants .DisableRuntime + "=false" ),
320+ e2e .OptAppendEnv (fmt .Sprintf ("%s=%s" , constants .AppInstallDirOverrideEnvVarName , appInstallDir )),
321+ e2e .OptAppendEnv (fmt .Sprintf ("%s=FOO" , constants .OverrideSessionTokenEnvVarName )),
322+ e2e .OptAppendEnv (fmt .Sprintf ("%s=false" , constants .DisableActivateEventsEnvVarName )),
323+ }
324+ if runtime .GOOS == "windows" {
325+ cmd = "powershell.exe"
326+ opts = append (opts ,
327+ e2e .OptAppendEnv ("SHELL=" ),
328+ e2e .OptAppendEnv (constants .OverrideShellEnvVarName + "=" ),
329+ )
330+ }
331+ cp := ts .SpawnCmdWithOpts (cmd , opts ... )
332+ cp .Expect ("Preparing Installer for State Tool Package Manager" )
333+ if runtime .GOOS == "windows" {
334+ cp .Expect ("Continuing because the '--force' flag is set" ) // admin prompt
335+ }
336+ cp .Expect ("Installation Complete" , e2e .RuntimeSourcingTimeoutOpt )
337+
338+ cp .SendLine ("exit" )
339+ cp .ExpectExitCode (0 )
340+
341+ stateExec , err := installation .StateExecFromDir (installDir )
342+ suite .NoError (err )
343+ suite .FileExists (stateExec )
344+
345+ suite .verifyConfigValue (ts , stateExec , "analytics.enabled" , "false" )
346+ suite .verifyConfigValue (ts , stateExec , "output.format" , "json" )
347+ suite .verifyConfigValue (ts , stateExec , "test.key1" , "value1" )
348+ suite .verifyConfigValue (ts , stateExec , "test.key2" , "value2" )
349+
350+ suite .verifyConfigValueDirect (ts , "analytics.enabled" , "false" )
351+ suite .verifyConfigValueDirect (ts , "output.format" , "json" )
352+ suite .verifyConfigValueDirect (ts , "test.key1" , "value1" )
353+ suite .verifyConfigValueDirect (ts , "test.key2" , "value2" )
354+ }
355+
356+ func (suite * InstallScriptsIntegrationTestSuite ) verifyConfigValue (ts * e2e.Session , stateExec , key , expectedValue string ) {
357+ cp := ts .SpawnCmd (stateExec , "config" , "get" , key )
358+ cp .ExpectExitCode (0 )
359+ output := strings .TrimSpace (cp .StrippedSnapshot ())
360+ suite .Equal (expectedValue , output , "Config value for key %s should be %s, got %s" , key , expectedValue , output )
361+ }
362+
363+ func (suite * InstallScriptsIntegrationTestSuite ) verifyConfigValueDirect (ts * e2e.Session , key , expectedValue string ) {
364+ cfg , err := config .NewCustom (ts .Dirs .Config , singlethread .New (), true )
365+ suite .Require ().NoError (err )
366+ defer cfg .Close ()
367+
368+ actualValue := cfg .GetString (key )
369+ suite .Equal (expectedValue , actualValue , "Config value for key %s should be %s, got %s (via config library)" , key , expectedValue , actualValue )
370+ }
371+
284372func (suite * InstallScriptsIntegrationTestSuite ) assertAnalytics (ts * e2e.Session ) {
285373 // Verify analytics reported a non-empty sessionToken.
286374 sessionTokenFound := false
0 commit comments