-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Submit prints out api error messages #770
Conversation
@Smarticles101 do you intend to continue working on this? |
I would recommend not using You can set up a mock server and set the status for the response by adding a header ( |
@jdsutherland yeah, just a bit busy recently. Thanks for the comments @kytrinyx, I should have some time today or tomorrow to try and throw a test together |
I implemented a test that whatever error message is returned by the server gets printed. I struggled with some For right now is it necessary that we even use |
Yeah, I don't think |
Agreed. My comment above was more to make sure that you didn't try to shoehorn your thing into |
I've been refactoring submit and noticed something I think might be worth pointing out. In thinking about validation for the We might want to handle 404's so that we get more appropriate error messages. I'm not sure how likely a bad ID is (I can think of programmer error or someone mangling the metadata file) but we might avoid potential future headache. |
Ouch, yes this is not good at all. @jdsutherland would you mind opening an issue for this? |
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.
Other than a couple of small comments with respect to variable naming, this is looking ready to go!
(I'm sorry it took so long to get to this @Smarticles101. It's been a rough few months).
cmd/submit_test.go
Outdated
fmt.Fprintf(w, `{"error": {"type": "error", "message": "test error"}}`) | ||
}) | ||
|
||
errts := httptest.NewServer(handler) |
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.
We only have one test server in this test, right? If so, can we name the variable ts
for consistency with the other tests? By giving it a different name I find myself reading everything more carefully to see in what way it is special or what the other servers in the test are called to require it to be special.
cmd/submit_test.go
Outdated
errts := httptest.NewServer(handler) | ||
defer errts.Close() | ||
|
||
tmpDir, err := ioutil.TempDir("", "secret-temp-dir") |
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.
Let's give this a prefix that reflects the purpose of the test. Maybe something like submit-error
@kytrinyx thanks for reviewing this and getting some of the other pull requests closed out. I’ll commit those changes when I get a chance in the upcoming days |
199ea1a
to
099a54c
Compare
This should be ready for review now, I've resolved your comments @kytrinyx, resolved merge conflicts and then squashed the changes into one commit. :) |
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.
Awesome, @Smarticles101, thanks for your patience and for following up on all the comments!
Closes #768
I mostly copied this after the code similar to it in
cmd/download
. It should print out any error message the api returns.I haven't implemented tests, but I have some thoughts on it.
fakeSubmitServer
should test for some case where the api should return an error message (like when a duplicate submission happens) and then the test should check thatrunSubmit
returns an error. Not sure how to do this though. I'm a go noob 😛