mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Modify the tfvars test to also use a cli var
Modify the test to demonstrate where cli vars were being lost because they weren't interpreted as strings.
This commit is contained in:
parent
9d0faa2cae
commit
d5fbb5f5c0
@ -389,6 +389,8 @@ func TestPush_tfvars(t *testing.T) {
|
|||||||
args := []string{
|
args := []string{
|
||||||
"-var-file", path + "/terraform.tfvars",
|
"-var-file", path + "/terraform.tfvars",
|
||||||
"-vcs=false",
|
"-vcs=false",
|
||||||
|
"-var",
|
||||||
|
"bar=1",
|
||||||
path,
|
path,
|
||||||
}
|
}
|
||||||
if code := c.Run(args); code != 0 {
|
if code := c.Run(args); code != 0 {
|
||||||
@ -412,12 +414,19 @@ func TestPush_tfvars(t *testing.T) {
|
|||||||
|
|
||||||
//now check TFVars
|
//now check TFVars
|
||||||
tfvars := pushTFVars()
|
tfvars := pushTFVars()
|
||||||
|
// update bar to match cli value
|
||||||
|
for i, v := range tfvars {
|
||||||
|
if v.Key == "bar" {
|
||||||
|
tfvars[i].Value = "1"
|
||||||
|
tfvars[i].IsHCL = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for i, expected := range tfvars {
|
for i, expected := range tfvars {
|
||||||
got := client.UpsertOptions.TFVars[i]
|
got := client.UpsertOptions.TFVars[i]
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Logf("%2d expected: %#v", i, expected)
|
t.Logf("%2d expected: %#v", i, expected)
|
||||||
t.Logf(" got: %#v", got)
|
t.Fatalf(" got: %#v", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -589,9 +598,8 @@ func pushTFVars() []atlas.TFVar {
|
|||||||
{"baz", `{
|
{"baz", `{
|
||||||
A = "a"
|
A = "a"
|
||||||
interp = "${file("t.txt")}"
|
interp = "${file("t.txt")}"
|
||||||
}
|
}`, true},
|
||||||
`, true},
|
{"fob", `["a", "quotes \"in\" quotes"]`, true},
|
||||||
{"fob", `["a", "quotes \"in\" quotes"]` + "\n", true},
|
|
||||||
{"foo", "bar", false},
|
{"foo", "bar", false},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user