-
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.
test: also allow mock_data and mock_resource blocks to generate data …
…during planning (#36317)
- Loading branch information
1 parent
e5d4a51
commit 408f323
Showing
12 changed files
with
120 additions
and
80 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
6 changes: 6 additions & 0 deletions
6
internal/command/testdata/test/mocking/tests/mocks/data.tfmock.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 @@ | ||
mock_resource "test_resource" { | ||
override_during = plan | ||
defaults = { | ||
id = "aaaa" | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
internal/command/testdata/test/mocking/tests/primary_mocked_external.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,47 @@ | ||
mock_provider "test" { | ||
alias = "primary" | ||
|
||
source ="./tests/mocks" | ||
} | ||
|
||
mock_provider "test" { | ||
alias = "secondary" | ||
|
||
mock_resource "test_resource" { | ||
override_during = plan | ||
defaults = { | ||
id = "bbbb" | ||
} | ||
} | ||
} | ||
|
||
variables { | ||
instances = 1 | ||
child_instances = 1 | ||
} | ||
|
||
|
||
run "test" { | ||
command = plan | ||
|
||
assert { | ||
condition = test_resource.primary[0].id == "aaaa" | ||
error_message = "did not apply mocks" | ||
} | ||
|
||
assert { | ||
condition = module.child[0].primary[0].id == "aaaa" | ||
error_message = "did not apply mocks" | ||
} | ||
|
||
assert { | ||
condition = test_resource.secondary[0].id == "bbbb" | ||
error_message = "wrongly applied mocks" | ||
} | ||
|
||
assert { | ||
condition = module.child[0].secondary[0].id == "bbbb" | ||
error_message = "wrongly applied mocks" | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.