-
Notifications
You must be signed in to change notification settings - Fork 78
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
Tech Debt: Simplify unit tests by using UnstructuredSet & ObjMetadataSet with AssertEqual deep comparison #428
Comments
I've just bumped the version of cli-utils I use and found the p.s. Also, I think ideally methods for testing should live in a separate package and not on a type that is used in production code. |
The Equal ignores order and duplicates when comparing the set. Having an Equal on the list also allows comparison of structs that contain the list. It also indicates to callers that input/output order isn’t important while still allowing cli-utils to sort it without a huge refactor. |
Ok, I see the description of When using The benefit of this approach is that
I don't mind the alias per se, I think it makes sense to have it as a way to carry the semantics (and doc) on it. |
So if we build a a := ... // a is a struct/slice/map, containing UnstructuredSet
b := ... // b is a struct/slice/map, containing UnstructuredSet
assert.Empty(t, cmp.Diff(a, b, cliUtilsTesting.TransformUnstructuredSet())) I use |
I added a testutil.assertEqual/assertNotEqual already that prints a diff on failure. We’re using it for event comparison already in the e2e tests. It doesn’t currently sort the elements for the diff, but we could make it use the transformer pattern before diffing. There’s already a sorter in the ordering package. I’m hoping to just get rid off the ExpEvent objects all together and compare actual events, but it requires some more enhancements to make things in the event structs more comparable first. There’s some annoyingly deep recursion happening in them that probably shouldn’t have been exposed in a public facing API. Anyway, I’ll take a stab at using the new sets for the unit tests. It’s should make it clear what other enhancements are needed. But yes, getting a clear and actionable error on failure is definitely one of the goals. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
Follow up after #419 and #426
/assign @karlkfi
The text was updated successfully, but these errors were encountered: