-
Notifications
You must be signed in to change notification settings - Fork 460
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
Add new constants, rename one and fix DueBy #583
Conversation
"verification": map[string]interface{}{ | ||
"disabled_reason": "fields_needed", | ||
"due_by": 1528573382, | ||
"fields_needed": []interface{}{ |
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.
You have no idea how long I spent on figuring out the write right combination of []
string
map
interface
and {}
to make that one work 😓
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.
Oh god, haha.
assert.Equal(t, true, account.ExternalAccounts.HasMore) | ||
|
||
assert.Equal(t, 2, len(account.ExternalAccounts.Data)) | ||
assert.Equal(t, "ba_123", account.ExternalAccounts.Data[0].ID) | ||
assert.Equal(t, "card_123", account.ExternalAccounts.Data[1].ID) | ||
|
||
// Ensure LegalEntity is fully deserialized |
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.
I made thorough tests of almost every property, not sure if too much or not, please let me know if I should cut those in half.
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.
Probably not necessary, but I think it's okay now that you've already written it.
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.
Out of curiosity what do you think would have been a good test? I think this large structure is fairly easy to mess up as there are so many edge-cases. You could end up deserializing the wrong property in the wrong place like maiden name as first_name or vice versa, or identification documents like I did.
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.
Probably one check per "level" (i.e., level of structures which you descend to) is probably a good idea. Agree that it's easy to misname a JSON field, but I think to some degree you need to rely on the fact that these are likely to trend towards correctness over time. Adding tests gives you a little more guarantee, but the tests themselves are likely to be butchered during any sizable refactor, and so not end up testing for regressions as well as you might hope anyway.
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.
Gotcha! I see where you're coming from. I think I had similar discussions with @ob-stripe on the stripe-java refactor so it is starting to make sense to me.
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.
Yeah, it's definitely a little subjective :$
@remi-stripe JFYI: There are more struct fields of type Would be nice if these changes would find their way into the library soon. |
@nd2s That is expected. You can see that all parameters are Instead your code should be:
|
+1. This LGTM. |
Released as 33.0.0. |
Bumps [sorbet](https://github.com/sorbet/sorbet) from 0.5.10151 to 0.5.10172. - [Release notes](https://github.com/sorbet/sorbet/releases) - [Commits](https://github.com/sorbet/sorbet/commits) --- updated-dependencies: - dependency-name: sorbet dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
While working on fixing #580, I started improving
TestAccountUnmarshal
to ensure we tried to deserialize a complex account object to catch any issue.Doing that, I caught a few mistakes that I wanted to fix at the same time:
AccountRejectReason
is now a type even though it's only used as a parameter. I should have fixed it when you asked me to, it's cleaner.verification[disabled_reason]
now has its own type:IdentityVerificationDisabledReason
and related constantsverification[due_by]
should not be a pointer so I fixed it back to a normalint64
PayoutIntervalDay
has been renamed toPayoutIntervalDaily
.I think we should merge this one as a major version as it makes enough breaking changes.
If we want to unblock the other issue without a major version though we could merge #582 first.
r? @brandur-stripe
cc @stripe/api-libraries