Skip to content
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

RawEquals: Sets with the same unknowns are equal enough for RawEquals #64

Merged

Conversation

mildwonkey
Copy link
Contributor

@mildwonkey mildwonkey commented Sep 2, 2020

RawEquals should return true when comparing sets with the same type and same unknown values.

I've copied all the tests from Equal (modified to match the expected result of RawEquals) - the only test that was failing before this change is this one:

		{
			ObjectVal(map[string]Value{
				"a": SetVal([]Value{
					ObjectVal(map[string]Value{
						"b": UnknownVal(String),
					}),
				}),
			}),
			ObjectVal(map[string]Value{
				"a": SetVal([]Value{
					ObjectVal(map[string]Value{
						"b": UnknownVal(String),
					}),
				}),
			}),
			true,
		},

I've also verified that this change doesn't cause any test failures in terraform.

@mildwonkey mildwonkey marked this pull request as draft September 2, 2020 14:21
@mildwonkey mildwonkey changed the title RawEquals: fall back to reflect.DeepEqual when comparing sets with unknowns. RawEquals: Sets with the same unknowns are equal enough for RawEquals Sep 2, 2020
@mildwonkey mildwonkey force-pushed the mildwonkey/b-set-raw-equals branch 2 times, most recently from 8abf026 to 339e698 Compare September 2, 2020 18:30
@mildwonkey mildwonkey marked this pull request as ready for review September 2, 2020 18:31
Sets with the same type and same unknown values are equal enough for
RawEqual's purposes. This commit takes advantage of the setRules's
defined ordering to compare each element of the set.
@codecov
Copy link

codecov bot commented Sep 2, 2020

Codecov Report

Merging #64 into master will increase coverage by 0.32%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #64      +/-   ##
==========================================
+ Coverage   70.85%   71.17%   +0.32%     
==========================================
  Files          79       79              
  Lines        7284     7276       -8     
==========================================
+ Hits         5161     5179      +18     
+ Misses       1670     1654      -16     
+ Partials      453      443      -10     
Impacted Files Coverage Δ
cty/value_ops.go 86.15% <100.00%> (+2.45%) ⬆️
cty/marks.go 80.98% <0.00%> (+1.40%) ⬆️
cty/convert/compare_types.go 100.00% <0.00%> (+7.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f54e9ad...0780fd3. Read the comment docs.

@apparentlymart
Copy link
Collaborator

Thanks! This makes sense to me, and fixes the bug I introduced in my latest changes.

@apparentlymart apparentlymart merged commit 9f97db4 into zclconf:master Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants