-
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
Expose internal SDKv2 Diff cross-test interface #2720
Conversation
This change is part of the following stack:
Change managed by git-spice. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2720 +/- ##
=======================================
Coverage 69.63% 69.64%
=======================================
Files 301 301
Lines 38725 38725
=======================================
+ Hits 26967 26970 +3
+ Misses 10240 10238 -2
+ Partials 1518 1517 -1 ☔ View full report in Codecov by Sentry. |
580f476
to
1668a0c
Compare
} | ||
|
||
func Diff( | ||
t T, resource *schema.Resource, config1, config2 map[string]cty.Value, opts ...DiffOption, |
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.
Create
and Configure
both take a map[string]*schema.Schema
instead of a *schema.Resource
. This is to intentionally constrain the inputs to Diff
to only options that can be exercised in Diff
based tests.
We will probably want an option for schema.Resource.CustomizeDiff
. We don't want users to be able to set schema.Resource.Importer
.
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.
Yeah, this unfortunately limits the expressiveness of the test too - for example custom Create and Update methods might be required in a Diff test for implementing Computed properties. Instead of re-implementing the API with options we should have a simple check for the banned inputs. In the case of Diff tests, I don't think there are any schema inputs which should be banned - this only applies to, for example, custom Create in Create cross-tests.
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.
I don't see what Resource.Importer
has to do with Diff test
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.
I don't see a good reason why we would choose to add a new interface there for specifying schemas instead of reusing the default TF SDK one - it works well enough and allows us to copy-paste provider examples and avoids unnecessary complexity.
I can add refactoring the other cross-test interfaces to my TODO list
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.
I'm on the side of being more permissive here in the internal test code.
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.
I don't see a good reason why we would choose to add a new interface there for specifying schemas instead of reusing the default TF SDK one
Because it keeps the tests intentional. We only add properties that can actually be tested.
it works well enough and allows us to copy-paste provider examples and avoids unnecessary complexity.
I'd rather we didn't copy-paste whole resources to test only a small part of them.
I don't see what Resource.Importer has to do with Diff test
Nothing at all, but I can set .Importer
on a *schema.Resource
and pass that to crosstests.Diff
with this design. I'd rather that was a compiler error. I use that example because I remember someone setting .Importer
for a create and asserting that the .Importer
didn't panic.
I won't block the PR on this, but IMO passing *schema.Resource
directly makes the tests easier to write but harder to read.
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.
passing *schema.Resource directly makes the tests easier to write but harder to read.
I don't agree about readability either. I think the benefit of options is that it is harder to get the Schema wrong. Given that there's very few people who actually write these type of tests, I think it's worth keeping it simple for now and evolving the interface once we find a need to.
Let's revisit once we have a concrete problem we are solving with the extra interface.
1668a0c
to
899f5d0
Compare
899f5d0
to
5fec1c6
Compare
This PR has been shipped in release v3.98.0. |
This is a test-only change. It exposes an internal Diff cross-test interface for the SDKv2 bridge. It currently just calls the
runDiffCheck
function.