Skip to content

Commit

Permalink
Fix endpoint path
Browse files Browse the repository at this point in the history
  • Loading branch information
osamingo committed Feb 17, 2022
1 parent d53fc88 commit 3a860d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kenall.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (cli *Client) GetAddress(ctx context.Context, postalCode string) (*GetAddre
return nil, ErrInvalidArgument
}

const path = "/postalCode/"
const path = "/postalcode/"

req, err := http.NewRequestWithContext(ctx, http.MethodGet, cli.Endpoint+path+postalCode, nil)
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions kenall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func runTestingServer(t *testing.T) *httptest.Server {
}

switch path := r.URL.Path; {
case strings.HasPrefix(path, "/postalCode/"):
case strings.HasPrefix(path, "/postalcode/"):
handlePostalAPI(t, w, path)
case strings.HasPrefix(path, "/cities/"):
handleCityAPI(t, w, path)
Expand All @@ -296,21 +296,21 @@ func handlePostalAPI(t *testing.T, w http.ResponseWriter, path string) {
t.Helper()

switch path {
case "/postalCode/1008105":
case "/postalcode/1008105":
if _, err := w.Write(addressResponse); err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
case "/postalCode/4020000":
case "/postalcode/4020000":
w.WriteHeader(http.StatusPaymentRequired)
case "/postalCode/4030000":
case "/postalcode/4030000":
w.WriteHeader(http.StatusForbidden)
case "/postalCode/4050000":
case "/postalcode/4050000":
w.WriteHeader(http.StatusMethodNotAllowed)
case "/postalCode/5000000":
case "/postalcode/5000000":
w.WriteHeader(http.StatusInternalServerError)
case "/postalCode/5030000":
case "/postalcode/5030000":
w.WriteHeader(http.StatusServiceUnavailable)
case "/postalCode/0000001":
case "/postalcode/0000001":
if _, err := w.Write([]byte("wrong")); err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
Expand Down

0 comments on commit 3a860d6

Please sign in to comment.