-
Notifications
You must be signed in to change notification settings - Fork 244
Switch api.line.me and api-data.line.me depending on API methods #181
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
Switch api.line.me and api-data.line.me depending on API methods #181
Conversation
Codecov Report
@@ Coverage Diff @@
## master #181 +/- ##
==========================================
+ Coverage 74.19% 75.55% +1.35%
==========================================
Files 25 25
Lines 1984 1996 +12
==========================================
+ Hits 1472 1508 +36
+ Misses 426 394 -32
- Partials 86 94 +8
Continue to review full report at Codecov.
|
f81b047 to
19b9b7c
Compare
| dataServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| defer r.Body.Close() | ||
| w.WriteHeader(404) | ||
| w.Write([]byte(`{"message":"Not found"}`)) |
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.
How about calling t.Error in this handler?
we want to know dataServer is not called
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.
3c28b82 applies changes to make the intention clearer.
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.
should be responses 200? double error will be occurred
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’m not sure where this p-r is going.
Just to make sure, are you saying that this should return the HTTP status code of 200 and the expected response? And only leave error state for the wrong API endpoint call? The tests I added kind of focus on the behavior of target API. It is somewhat like “If a wrong endpoint is called, then an unexpected response is returned and hence following test items fail.”
Honestly, the more I read tests in this repository I get more confused. For example, subtests are executed in a loop, but a httptest.Server is constructed outside of the loop and it still refers to testing.T which does not belong to the subtest. So the nested output of the test would look pretty weird.
And some request methods have benchmark tests but some do not. The benchmark actually points to a mock server so the main differences would be the time elapsed for payload serialization and deserialization. Probably this is because all XxxCalls currently have Do method so it seemed like all request methods needed to have benchmark tests as long as one was created for a certain method, but I am not sure about the consequence.
I started with a minimal code change before the first code review because a) this had to be merged prior to the notified date and b) some pull requests with potential conflicts were under review. But now it involves changes for overall architecture including the signature changes of mockClient while the deadline is getting close.
Probably I should close this p-r and let someone familiar with this repository’s policy take over so this issue can be handled in a short time.
Fixes #179
To switch the API domain name, this p-r introduces a mechanism to explicitly set and pass base URL in each
XxxCallimplementation.I noticed
examples/richmenu_helper/main.gowas missing "download" mode even though it was part of the acceptable mode list. To test integration 163f81f adds an implementation for "download."