Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
exp/lighthorizon/actions: use standard Problem model on API error responses #4542
exp/lighthorizon/actions: use standard Problem model on API error responses #4542
Changes from 2 commits
128b699
2f356d8
8c9f811
77bdead
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
By using mocking here, are we omitting testing of the actual behavior in relation to transaction querying? e.g. I don't see tests for 404s on a missing account. And a lot of these errors actually happen before
TransactionService.GetTransactionsByAccount()
gets invoked, right? Parameter validation, etc. happens beforehand. I think we'd get better coverage if we mock exactly what needs to be mocked (e.g. 500s).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 think that is what is mocked here, have told the data access function to throw an error
not good
which represents unrecoverable/unexpected err from code, equates to server-side 500 response.Haven't added tests on 404's because the app layer hasn't determined that yet, it's returning empty list responses when the index reports no
NextActive()
, maybe because absence of the account is not as deterministic here since we don't have current state, just what exists after some range is indexed? maybe we just need to be consistent and choose whether to return 404's or empty list, I think with a stateless cursor API, the empty list response may feel more natural. since client would get data for each cursor fetch iteration, until the last cursor fetch would give empty list instead of 404.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.
Sorry, I put this comment in the wrong place. I meant for it to apply to the test in
TestTxByAccountMissingParamError
, but I don't think it applies there anymore, either, thinking about it more. Since the mocked code (TransactionService
) never gets reached before hitting the 400 error like I said, it doesn't matter if it's mocked out or not.Re: 404s, we can still distinguish between
account_id
not being in the index (which would be a 404) vs.NextActive()
returning EOF (which would be an empty tx list). I see what you mean about a partial view of the world, but it still counts as a 404 imo: if the ledger range you indexed doesn't have any activity for an account, a 404 is a valid description of the account.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.
file naming: maybe
test_helpers.go
? since there are no tests here. I expected to see tests for helpers heh. tiny nitpick though so feel free to ignore.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.
might as well use
require
here for brevity