-
Notifications
You must be signed in to change notification settings - Fork 486
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
Decode / encode tests #4443
Decode / encode tests #4443
Conversation
3c9cc98
to
aa98c70
Compare
case fieldValue.IsZero(): | ||
// It shouldn't be possible to have a required block which is unset, but | ||
// we'll encode something anyway. | ||
inner := NewBlock(fullName, "") | ||
inner.body.SetValueOverrideHook(b.valueOverrideHook) | ||
b.AppendBlock(inner) | ||
|
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.
Here a zero struct is encoded as empty block in River. When it's decoded, the defaults will be applied, so we wouldn't get the same value as we encoded.
Luckily all we need to do is remove this case and the other cases will handle it correctly, taking defaults into account.
ab0fc11
to
2539217
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.
Thanks Piotr!
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. I'm considering whether we should merge this as-is and deal with the commented out tests in a follow up discussion. WDYT?
51c2091
to
30ecfc3
Compare
PR Description
This PR adds tests that cover different cases of nested blocks with defaults etc.
Furthermore, this PR:
PR Checklist