-
Notifications
You must be signed in to change notification settings - Fork 44
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
Full fidelity SDKv2 crosstest.Create
equality
#2840
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2840 +/- ##
==========================================
- Coverage 67.49% 67.48% -0.01%
==========================================
Files 325 325
Lines 41621 41633 +12
==========================================
+ Hits 28093 28097 +4
- Misses 11951 11957 +6
- Partials 1577 1579 +2 ☔ View full report in Codecov by Sentry. |
b38a215
to
34c02db
Compare
Supply `tfprotov5.ApplyResourceChangeRequest.ProviderMeta` when we call `ApplyResourceChange` in SDKv2 providers. This gets us to a byte for byte identical result for SDKv2 `crosstest.Create`. This allows us to simplify (and strengthen) the comparison to general equality. Related to #2521
34c02db
to
b4300c5
Compare
// `assert`'s default `reflect.DeepEqual` because cmp treats identical | ||
// function pointers as equal, but `reflect.DeepEqual` does not. | ||
opts := []cmp.Option{ | ||
cmp.Exporter(func(reflect.Type) bool { return true }), |
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.
This has cmp
compare all un-exported fields.
cmp.Comparer(func(x, y schema.SchemaStateFunc) bool { | ||
return reflect.ValueOf(x).Pointer() == reflect.ValueOf(y).Pointer() | ||
}), |
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.
This implements pointer equality for schema.SchemaStateFunc
.
var providerMetaVal []byte | ||
if providerMeta != nil { | ||
providerMetaVal, err = msgpack.Marshal(*providerMeta, providerMeta.Type()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} else { | ||
providerMetaVal, err = msgpack.Marshal(cty.NullVal(cty.EmptyObject), cty.EmptyObject) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} |
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.
The previous compare function wasn't catching this, but the new comparison does. This now more accurately imitates TF.
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
Supply
tfprotov5.ApplyResourceChangeRequest.ProviderMeta
when we callApplyResourceChange
in SDKv2 providers. This gets us to a byte for byte identical result for SDKv2crosstest.Create
. This allows us to simplify (and strengthen) the comparison to general equality.Related to #2521