-
Notifications
You must be signed in to change notification settings - Fork 910
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
Testing: When mocking a resource, wrong type for the resource field doesn't fail, simply ignores mock #1839
Comments
@cam72cam Can you please assign it to me and also give me some directions? |
Hey @pooriaghaedi! Thank you for volunteering, I've assigned you. Please read the "I've been assigned an issue, now what?" section of the contribution guide before you begin working. In mocks and overrides, we use You can go through the diags creation in |
Hi @ollevche, I have tested the same code with tests/my-test.tftest.hcl... fail
run "test"... fail
╷
│ Warning: Ignored mock/override field `domain_validation_options`
│
│ with aws_acm_certificate.this,
│ on main.tf line 5, in resource "aws_acm_certificate" "this":
│ 5: resource "aws_acm_certificate" "this" {
│
│ Values provided for override / mock must match resource fields types: set of object required, but received number.
│
│ (and one more similar warning elsewhere)
╵
╷
│ Error: Test assertion failed
│
│ on tests/my-test.tftest.hcl line 13, in run "test":
│ 13: condition = one(aws_acm_certificate.this.domain_validation_options) == 2
│ ├────────────────
│ │ aws_acm_certificate.this.domain_validation_options is empty set of object
│
│ domain validation options is empty?
╵
Failure! 0 passed, 1 failed. Should we consider this as resolved or does it still need investigation? |
Hey @pooriaghaedi, the test assertion fails because the condition has not been met. If you change the condition to check against the empty set of objects, it will succeed. We want tofu to fail due to mismatched mock / override types, which currently results in a warning. We should also review other warnings in MockValueComposer and turn some of them into errors. |
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (opentofu#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (#1839) Signed-off-by: pooriaghaedi <[email protected]>
…a resource (#1839) Signed-off-by: pooriaghaedi <[email protected]>
OpenTofu Version
OpenTofu Configuration Files
main.tf
tests/my-test.tftest.hcl
Debug Output
.
Expected Behavior
Should error, saying that the mocked
domain_validation_options
has an incompatible typeActual Behavior
Test continues to run, and the mock is ignored
Steps to Reproduce
tofu init
tofu test
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: