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

chore: add integration test for omitempty encoding at ingress #1450

Merged
merged 2 commits into from
May 9, 2024

Conversation

deniseli
Copy link
Contributor

@deniseli deniseli commented May 9, 2024

Addresses #1441 (comment)

Tested with go test --tags=integration ./integration/... -run TestHTTPEncodeOmitempty

@deniseli deniseli requested a review from alecthomas as a code owner May 9, 2024 18:41
@deniseli deniseli requested review from a team and matt2e and removed request for a team May 9, 2024 18:41
@alecthomas alecthomas mentioned this pull request May 9, 2024
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Nice!

@alecthomas
Copy link
Collaborator

Does omitempty work for optional types?

@deniseli
Copy link
Contributor Author

deniseli commented May 9, 2024

Does omitempty work for optional types?

Yes! Though it encodes to null rather than "" for an ftl.None[string](). I realized I missed that branch case in the unit tests so I added that in too :)

@alecthomas
Copy link
Collaborator

omitempty in conjunction with Option should result in the field being omitted entirely - you should be able to use reflect.Value.IsZero() to check that case

@wesbillman
Copy link
Collaborator

Nice one @deniseli!!

@deniseli
Copy link
Contributor Author

deniseli commented May 9, 2024

Ah, sorry, I misspoke entirely last time. The field that is tagged omitempty is indeed omitted completely. The null is just for the cases where it the field is an ftl.Option but not tagged omitempty. So looks like we're good, I'll go ahead and merge. Sorry for the confusion!

@deniseli deniseli merged commit af7a19a into main May 9, 2024
10 checks passed
@deniseli deniseli deleted the dli/gotest-omitempty branch May 9, 2024 20:09
@alecthomas
Copy link
Collaborator

Oh nice, perfect!

@matt2e matt2e added the approved Marks an already closed PR as approved label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Marks an already closed PR as approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants