-
Notifications
You must be signed in to change notification settings - Fork 43
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 extract schema inputs tests for sdkv2 #2224
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2224 +/- ##
==========================================
+ Coverage 60.66% 62.49% +1.82%
==========================================
Files 356 355 -1
Lines 46430 38625 -7805
==========================================
- Hits 28169 24137 -4032
+ Misses 16701 12927 -3774
- Partials 1560 1561 +1 ☔ View full report in Codecov by Sentry. |
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.
non-blocking:
Can you give an explicit summary in the PR description for what exactly these tests are testing? Three months from now we'll really appreciate the context.
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.
similarly: can the test names be a bit more descriptive too? It's a lot of tests and I'd like to see names such as TestExtractInputsFromOutputsSdkv2/string_outputs_map_to_string_inputs
or something like that. In a test suite, TestExtractInputsFromOutputsSdkv2/string
is not that meaningful.
This adds adds missing test coverage for `ExtractInputsFromOutputs` for various PF schemas. `ExtractInputsFromOutputs` is a shared function so we should have coverage on both sides to make sure we don't cause regressions when fixing one. Similar to #2224 but on the PF side. This is in preparation for #2181 for #2180. Seeing some more evidence of #2218 here.
Fixes an issue with the SDKv2 and PF input extraction. During import we wrongly return values for properties which are fully computed which causes invalid programs to be generated. ~The object check in `CastToTypeObject` was wrong for SDKV2 objects: https://github.com/pulumi/pulumi-terraform-bridge/blob/48fd41bd16e2f7f933bb9390ab7619d52faabb6d/pkg/tfshim/util/types.go#L36~ The `CastToTypeObject` object check is wrong for both SDKv2 and PF. For the SDKV2 only sets and lists can have a `Resource` `.Elem`. For PF it list-nested blocks are represented with a `Resource` `.Elem` in the shim layer, so the check did not catch these. PF details here: #2231 This fixes the check and adds regression tests for the broken imports which resulted from 2180. Test coverage added in #2224 for sdkv2 and #2225 for pf. fixes #2180 depends on pulumi/providertest#91 stacked on #2225
This PR has been shipped in release v3.88.0. |
This adds test cases for how TF types are handled by
ExtractInputsFromOutputs
in combination withDefault
andComputed
andMaxItems: 1
ExtractInputsFromOutputs
is the function inschema.go
responsible for generating the inputs from resource outputs when a resource is imported. Its output is what the engine then uses for generating the code for the import.Notably, nested computed values are wrong for both max items one and non-max items one.
In #2180 we found a regression there, so this fills in some missing coverage.
Extracting the tests to make the changes more apparent and to make sure we don't regress in #2181