Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
osamingo committed Feb 16, 2023
1 parent 0220bad commit 57a0f61
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func TestClient_GetBusinessDays(t *testing.T) {
}{
"Normal case": {endpoint: srv.URL, token: "opencollector", ctx: context.Background(), giveTime: time.UnixMilli(1672498800000), checkAsError: false, wantError: nil, wantResult: true},
"Empty case": {endpoint: srv.URL, token: "opencollector", ctx: context.Background(), giveTime: time.Time{}, checkAsError: true, wantError: kenall.ErrInvalidArgument, wantResult: false},
"Wrong response": {endpoint: srv.URL, token: "opencollector", ctx: context.Background(), giveTime: time.Time{}.Add(time.Hour), checkAsError: true, wantError: &json.MarshalerError{}, wantResult: false},
"Wrong response": {endpoint: srv.URL, token: "opencollector", ctx: context.Background(), giveTime: time.Time{}.Add(24 * time.Hour), checkAsError: true, wantError: &json.MarshalerError{}, wantResult: false},
"nil context": {endpoint: srv.URL, token: "opencollector", ctx: nil, giveTime: time.Now(), checkAsError: true, wantError: &url.Error{}, wantResult: false},
}

Expand Down Expand Up @@ -925,6 +925,10 @@ func handleBusinessDaysAPI(t *testing.T, w http.ResponseWriter, uri string) {
if _, err := w.Write(businessDaysResponse); err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
case "/businessdays/check?date=0001-01-02":
if _, err := w.Write([]byte(`{"result": "worng"}`)); err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
default:
w.WriteHeader(http.StatusNotFound)
}
Expand Down

0 comments on commit 57a0f61

Please sign in to comment.