Skip to content

Commit

Permalink
fixed deprecated env prefix migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerugbo committed Jun 17, 2024
1 parent c3c01d3 commit a31da69
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/core/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,30 @@ func TestUpdateAgentConfig(t *testing.T) {
func TestDeprecatedEnvPrefixMigration(t *testing.T) {
want := true

t.Setenv("NMS_TLS_SKIP_VERIFY", "true")
curDir, err := os.Getwd()
require.NoError(t, err)

SetDefaults()
RegisterFlags()
tempConfDeleteFunc, err := sysutils.CopyFile(fmt.Sprintf("%s/%s", testCfgDir, emptyConfigFile), tempCfgFile)
defer func() {
err := tempConfDeleteFunc()
require.NoError(t, err, "deletion of temp config file failed")
}()
require.NoError(t, err)

tempDynamicDeleteFunc, err := sysutils.CopyFile(fmt.Sprintf("%s/%s", testCfgDir, emptyConfigFile), tempDynamicCfgFile)
defer func() {
err := tempDynamicDeleteFunc()
require.NoError(t, err, "deletion of temp dynamic config file failed")
}()
require.NoError(t, err)

cleanEnv(t, tempCfgFile, fmt.Sprintf("%s/%s", curDir, tempDynamicCfgFile))
setEnvVariable(t, "tls_skip_verify", "true")

config, err := GetConfig("1234")
require.NoError(t, err)

got := MigratedEnv
got := config.TLS.SkipVerify
assert.Equal(t, want, got)
}

Expand Down

0 comments on commit a31da69

Please sign in to comment.