-
Notifications
You must be signed in to change notification settings - Fork 12
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 handling string containing object for NewJSONInput
and use table tests for JSON
#365
Conversation
95423ed
to
d08c9fc
Compare
NewJSONInput
and use table tests for JSON
res, err := ol.NewJSONSchema(validStringContainingJSON) | ||
resVal := *res | ||
autopilot.Ok(t, err) | ||
autopilot.Equals(t, resVal["name"], "Thomas") |
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.
Removed because all these equals
checks are done by reflect.DeepEqual anyways, which is what autopilot.Equals is doing.
@@ -10,7 +10,34 @@ import ( | |||
"github.com/rocktavious/autopilot/v2023" | |||
) | |||
|
|||
var validStringContainingJSON = `{"name":"Thomas","isIntern":false,"age":45,"access":{"aws":"admin","okta":"admin"},"tags":["org:engineering","team:platform"]}` |
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.
Removed the "age":45,
here because it is annoying to have reflect.DeepEqual
fail to compare a int to a float64. This is handled by JSON marshal, we don't get any benefits from testing this on our own. We just need to make sure that keys and values are not being discarded.
cb5ef18
to
b5326b5
Compare
b5326b5
to
24eaa55
Compare
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! 🎉
Issues
Part of: OpsLevel/kubectl-opslevel#244 / https://github.com/OpsLevel/product/issues/8
Changelog
NewJSONInput
will stop adding extra backslashes to unnecessarily escape"{\"foo\": \"bar\"}"
. This is the only functional change.NewJSONInput
,NewJSON
,NewJSONSchema
)changie
entryBefore/after
Before I had to make this change in k8s sync in order for syncing object/array properties that are defined in
.metadata.annotations
(handled as a string):This
if
clause is no longer necessary.