-
Notifications
You must be signed in to change notification settings - Fork 150
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
fix Delta.DifferentAt behavior via changes to Path.Contains #20
Conversation
Hi @echen-98. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pkg/compare/path.go
Outdated
@@ -51,14 +51,30 @@ func (p Path) Pop() { | |||
} | |||
} | |||
|
|||
// Contains returns true if the supplied string appears within the Path | |||
// TODO: case sensitivity? |
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.
should we keep case-sensitive comparison?
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 think so, yes. We expect case-sensitivity in all Go fields and I'd expect that these strings are reflections of Go fields.
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.
Ok, removed TODO comment
/ok-to-test |
require.True(d.DifferentAt("Baz.Y")) | ||
require.False(d.DifferentAt("Y")) // there is no diff for top-level field "Y" | ||
require.False(d.DifferentAt("Bar")) // diff exists but it was not added to Delta | ||
require.False(d.DifferentAt("Baz.Y.Z")) // subject length exceeds length of diff Path | ||
require.False(d.DifferentAt("Baz.Z")) // matches Path top-level field but not sub-field |
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.
++ Super clear test cases! Love it!
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.
agreed, excellent clarity @echen-98
pkg/compare/path.go
Outdated
@@ -51,14 +51,30 @@ func (p Path) Pop() { | |||
} | |||
} | |||
|
|||
// Contains returns true if the supplied string appears within the Path | |||
// TODO: case sensitivity? |
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 think so, yes. We expect case-sensitivity in all Go fields and I'd expect that these strings are reflections of Go fields.
/approve |
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.
Very nice, thanks Eric!
I left one comment below
pkg/compare/path.go
Outdated
/* Contains returns true if the supplied string, delimited on ".", matches | ||
p.parts up to the length of the supplied string. | ||
e.g. if the Path p represents "A.B": | ||
subject "A" -> true | ||
subject "A.B" -> true | ||
subject "A.B.C" -> false | ||
subject "B" -> false | ||
subject "A.C" -> false | ||
*/ |
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.
Please use // not /** .. */ for muiltiline comments :)
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.
You can also instruct godoc
to generate testable examples in the package documentation: https://blog.golang.org/examples / https://blog.golang.org/godoc
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.
Great stuff @echen-98 :) Thank you!
require.True(d.DifferentAt("Baz.Y")) | ||
require.False(d.DifferentAt("Y")) // there is no diff for top-level field "Y" | ||
require.False(d.DifferentAt("Bar")) // diff exists but it was not added to Delta | ||
require.False(d.DifferentAt("Baz.Y.Z")) // subject length exceeds length of diff Path | ||
require.False(d.DifferentAt("Baz.Z")) // matches Path top-level field but not sub-field |
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.
agreed, excellent clarity @echen-98
// Contains returns true if the supplied string, delimited on ".", matches | ||
// p.parts up to the length of the supplied string. |
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.
femto-nit: not sure if it's your IDE or editor changing the above, but comments should have a single space (not \t
) after the //
and before the first letter of the comment...
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.
Got it, will keep in mind for next time
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: echen-98, jaypipes, RedbackThomson, vijtrip2 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes issue aws-controllers-k8s/community#808