-
Notifications
You must be signed in to change notification settings - Fork 921
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
Add cloud function secrets tests #1704
Conversation
Let me check here, if all tests will succeed. |
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.
lgtm in principle.
Left a few comments regarding the new validate_plan_object
function
Plus one on the change, even though I don't agree with the use case: when you need an inventory just do not declare one and run the test, it spits out a fully made inventory for you ( The next person touching the CF module's secret example will override your nice compact inventories with generated ones containing all values. :) |
This good question maybe to consider in I do run But maybe this is just not worth the hassle. |
your approach makes sense but is too labour intensive, I would not adopt any practice that slows development down :) |
Let me expand a tiny bit on what I wrote above: while having concise inventory with only the values under actual test is a sensible and nice approach, I think that
So focusing too narrowly on the inventory takes us away from the main goal, and adds friction. |
I do agree with this change and I've actually had it in mind for a while. These are a couple situations that would be solved by this:
There are situations where you want an inventory, but not a very verbose one. The contributing guide is explicit in saying that you should trim down the generated inventory and keep only what is relevant to the use case you're testing.
This PR would actually achieve the opposite :) Using As a side note, we should probably provide a better tool/process to build inventories, but that's a different discussion. |
I do said I like this change. 😀 I don't think I will ever spend the time to trim down inventories, personally. YMMV of course |
I do. Mine and other people's too 🤫 |
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.
One more thing: can you move this comment to the function as a docstring and update its content accordingly?
For objects that are not simple attributes of the resource (i.e. objects, lists) allow specifing subset of values that needs to be verified. In case of lists, count of list objects must match, but if values are objects / dicts, they can be specified as empty dicts which should pass all the checks, as no keys are specified.
2115860
to
6d27322
Compare
Moved |
Additional tests for #1703 to catch such errors in the future.
In this case, for Cloud Functions v2 test, if I only want to test
secret_environment_variables
andsecret_volumes
, I still need to specify all non-important attributes in inventory, e.g.:Which is painful and requires unnecessary maintenance work in the future. Instead, test fixture was modified so no matter how nested the object is defined, only keys and values provided in the inventory are validated against the plan.
After the change, inventory contains only relevant info:
Checklist
I applicable, I acknowledge that I have:
terraform fmt
on all modified filestools/tfdoc.py