-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform test: Collect variables from default var file within testing directory #34341
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
357aaf6
Add logic to collect variables for terrafrom test
JKIPIKA c1bf38b
Add tests for test variable collection
JKIPIKA a6857ad
Update the test variable collection implementation
JKIPIKA ab59366
Update internal/backend/local/test.go
JKIPIKA ec4ecbd
Update internal/backend/local/test.go
JKIPIKA fbae1af
Move test variables into var file
JKIPIKA cb5b101
Merge branch 'hashicorp:main' into main
JKIPIKA fa723f3
resolve diff from cross-branch switch
liamcervante d67028f
go fmt
liamcervante File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
variable "foo" { | ||
description = "This is test variable" | ||
default = "def_value" | ||
} | ||
|
||
variable "fooJSON" { | ||
description = "This is test variable" | ||
default = "def_value" | ||
} | ||
|
||
output "out_foo" { | ||
value = var.foo | ||
} | ||
|
||
output "out_fooJSON" { | ||
value = var.fooJSON | ||
} |
13 changes: 13 additions & 0 deletions
13
internal/command/testdata/test/tfvars_in_test_dir/tests/main.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,13 @@ | ||
run "primary" { | ||
assert { | ||
condition = var.foo == var.test_foo | ||
error_message = "Expected: ${var.test_foo}, Actual: ${var.foo}" | ||
} | ||
} | ||
|
||
run "secondary" { | ||
assert { | ||
condition = var.fooJSON == var.test_foo_json | ||
error_message = "Expected: ${var.test_foo_json}, Actual: ${var.fooJSON}" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
internal/command/testdata/test/tfvars_in_test_dir/tests/terraform.tfvars
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,3 @@ | ||
foo = "foo_tfvars_value" | ||
test_foo = "foo_tfvars_value" | ||
test_foo_json = "foo_json_tfvars_value" |
3 changes: 3 additions & 0 deletions
3
internal/command/testdata/test/tfvars_in_test_dir/tests/terraform.tfvars.json
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,3 @@ | ||
{ | ||
"fooJSON": "foo_json_tfvars_value" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JKIPIKA, I resolved the diffs by undoing your changes to the other function and adding the relevant change directly in here instead.
You didn't do anything wrong, this function isn't available within the v1.6 branch so you did the right thing in your original PR. It's just we will have introduced this function at some point after the v1.6 launch for managing the global variables and it's much easier to add here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I get it now, thanks for explanation!