Merge pull request #4429 from DanHam/misc-fix

Fix win-shell test to use counter in index. Mirror test code from win-shell back to ps
This commit is contained in:
Matthew Hooker 2017-01-21 19:37:52 -08:00 committed by GitHub
commit a8d165a365
2 changed files with 18 additions and 33 deletions

View File

@ -310,37 +310,23 @@ func TestProvisionerQuote_EnvironmentVars(t *testing.T) {
"keyfive='value=five'",
"keysix='=six'",
}
expected := []string{
"keyone=valueone",
"keytwo=value\ntwo",
"keythree='valuethree'",
"keyfour='value\nfour'",
"keyfive='value=five'",
"keysix='=six'",
}
p := new(Provisioner)
p.Prepare(config)
expectedValue := "keyone=valueone"
if p.config.Vars[0] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[0], expectedValue)
}
expectedValue = "keytwo=value\ntwo"
if p.config.Vars[1] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[1], expectedValue)
}
expectedValue = "keythree='valuethree'"
if p.config.Vars[2] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[2], expectedValue)
}
expectedValue = "keyfour='value\nfour'"
if p.config.Vars[3] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[3], expectedValue)
}
expectedValue = "keyfive='value=five'"
if p.config.Vars[4] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[4], expectedValue)
}
expectedValue = "keysix='=six'"
if p.config.Vars[5] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[5], expectedValue)
for i, expectedValue := range expected {
if p.config.Vars[i] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[i], expectedValue)
}
}
}

View File

@ -207,6 +207,7 @@ func TestProvisionerPrepare_EnvironmentVars(t *testing.T) {
if err != nil {
t.Fatalf("should not have error: %s", err)
}
// Test when the env variable value contains an equals sign
config["environment_vars"] = []string{"good=withequals=true"}
p = new(Provisioner)
@ -237,7 +238,6 @@ func TestProvisionerQuote_EnvironmentVars(t *testing.T) {
}
expected := []string{
"keyone=valueone",
"keytwo=value\ntwo",
"keythree='valuethree'",
@ -250,9 +250,8 @@ func TestProvisionerQuote_EnvironmentVars(t *testing.T) {
p.Prepare(config)
for i, expectedValue := range expected {
if p.config.Vars[i] != expectedValue {
t.Fatalf("%s should be equal to %s", p.config.Vars[0], expectedValue)
t.Fatalf("%s should be equal to %s", p.config.Vars[i], expectedValue)
}
}
@ -425,7 +424,7 @@ func TestProvisioner_createFlattenedEnvVars_windows(t *testing.T) {
t.Fatalf("expected flattened env vars to be: %s, got: %s", expectedEnvVars, flattenedEnvVars)
}
// Environment variable with value containing equals. No Packer web server
// Environment variable with value containing equals
p.config.Vars = []string{"FOO=bar=baz"}
flattenedEnvVars, err = p.createFlattenedEnvVars()
if err != nil {
@ -436,7 +435,7 @@ func TestProvisioner_createFlattenedEnvVars_windows(t *testing.T) {
t.Fatalf("expected flattened env vars to be: %s, got: %s", expectedEnvVars, flattenedEnvVars)
}
// Environment variable with value starting with equals. No Packer web server
// Environment variable with value starting with equals
p.config.Vars = []string{"FOO==baz"}
flattenedEnvVars, err = p.createFlattenedEnvVars()
if err != nil {