-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
terraform test: Fix crash when file level variables reference variabl…
…es. (#34531) * terraform test: Fix crash when referencing variables within the file level variable block * also allow functions within variables blocks * add tests
- Loading branch information
1 parent
0994e6f
commit 430970c
Showing
7 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
internal/command/testdata/test/functions_available/alternate.tftest.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
variables { | ||
input = jsonencode({key:"value"}) | ||
} | ||
|
||
run "test" { | ||
assert { | ||
condition = jsondecode(test_resource.resource.value).key == "value" | ||
error_message = "wrong value" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
internal/command/testdata/test/global_var_refs/environment_variable.tftest.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
variables { | ||
input = var.env_var_input | ||
} | ||
|
||
run "execute" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
variable "input" { | ||
type = string | ||
} | ||
|
||
output "value" { | ||
value = var.input | ||
} |
17 changes: 17 additions & 0 deletions
17
internal/command/testdata/test/global_var_refs/run_block_output.tftest.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
variables { | ||
input = var.setup.value | ||
} | ||
|
||
run "setup" { | ||
variables { | ||
input = "hello" | ||
} | ||
} | ||
|
||
run "execute" { | ||
assert { | ||
condition = output.value == "hello" | ||
error_message = "bad output value" | ||
} | ||
} |