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

{Bool,Binary,UnixMilli}#MarshalJSON(): return valid JSON, not empty string #612

Conversation

Al2Klimov
Copy link
Member

in case an instance is null.

@Al2Klimov Al2Klimov added the bug Something isn't working label Jul 4, 2023
@Al2Klimov Al2Klimov requested a review from yhabteab July 4, 2023 13:39
@cla-bot cla-bot bot added the cla/signed label Jul 4, 2023
Copy link
Member

@yhabteab yhabteab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are fine, however if there were units for them from the beginning, such bugs would have been easy to spot. Thus, it would be nice if you could add the missing unit tests here as well.

@Al2Klimov Al2Klimov self-assigned this Jul 4, 2023
@Al2Klimov Al2Klimov force-pushed the bool-binary-unixmilli-marshaljson-return-valid-json-not-empty-string branch from 38de7ed to 698e332 Compare July 4, 2023 15:38
@Al2Klimov Al2Klimov removed their assignment Jul 4, 2023
@Al2Klimov Al2Klimov requested a review from yhabteab July 4, 2023 15:38
Copy link
Member

@yhabteab yhabteab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get why you're asserting the tests manually and with some type reflecting to top it all off. Why can't you just use require.* and assert.*?

pkg/types/binary_test.go Show resolved Hide resolved
@Al2Klimov
Copy link
Member Author

I copy&paste-d existing pkg/icingadb/objectpacker/objectpacker_test.go

@yhabteab
Copy link
Member

yhabteab commented Jul 5, 2023

I copy&paste-d existing pkg/icingadb/objectpacker/objectpacker_test.go

And why does it have to be exactly the same here? If you just want to extend the error messages and add some contexts in case of errors, you can do that with require.NoError(t, err, "test failed") as well. I don't see any advantage in checking the results manually with reflect.* and t.Errorf().

@Al2Klimov Al2Klimov force-pushed the bool-binary-unixmilli-marshaljson-return-valid-json-not-empty-string branch from 698e332 to b0f2aa3 Compare July 5, 2023 10:22
@Al2Klimov Al2Klimov requested a review from yhabteab July 5, 2023 10:22
@Al2Klimov Al2Klimov self-assigned this Jul 5, 2023
@Al2Klimov Al2Klimov force-pushed the bool-binary-unixmilli-marshaljson-return-valid-json-not-empty-string branch from b0f2aa3 to 4f3607f Compare July 5, 2023 15:24
pkg/types/binary_test.go Outdated Show resolved Hide resolved
pkg/types/binary_test.go Outdated Show resolved Hide resolved
pkg/types/binary_test.go Show resolved Hide resolved
Copy link
Member

@yhabteab yhabteab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Al2Klimov Al2Klimov assigned Al2Klimov and unassigned Al2Klimov Jul 6, 2023
@Al2Klimov Al2Klimov force-pushed the bool-binary-unixmilli-marshaljson-return-valid-json-not-empty-string branch from 4f3607f to 03d49a9 Compare July 6, 2023 09:22
@Al2Klimov Al2Klimov removed their assignment Jul 6, 2023
@Al2Klimov Al2Klimov force-pushed the bool-binary-unixmilli-marshaljson-return-valid-json-not-empty-string branch from 03d49a9 to 8815e04 Compare July 6, 2023 09:51
Copy link
Contributor

@julianbrost julianbrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give the sub-tests proper names. The spaces you use are not valid in test names so they are already replaces with _ and the special characters make it annoying to use with something like go test -run, which takes regexes, so escaping is needed:

go test -v -run 'TestUnixMilli_MarshalJSON/0001-01-01_00:00:00_\+0000_UTC_\(Unix:_-62135596800\)' ./pkg/types

@Al2Klimov Al2Klimov self-assigned this Jul 7, 2023
@Al2Klimov Al2Klimov force-pushed the bool-binary-unixmilli-marshaljson-return-valid-json-not-empty-string branch from 8815e04 to b8ed25c Compare July 7, 2023 14:48
@Al2Klimov Al2Klimov removed their assignment Jul 7, 2023
@julianbrost julianbrost merged commit ef09059 into master Jul 25, 2023
@julianbrost julianbrost deleted the bool-binary-unixmilli-marshaljson-return-valid-json-not-empty-string branch July 25, 2023 08:28
@julianbrost julianbrost added this to the 1.2.0 milestone Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cla/signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants