Skip to content

Commit

Permalink
Improving test case coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed May 11, 2020
1 parent 289f744 commit 6ad880c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
36 changes: 20 additions & 16 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,20 +828,8 @@ func TestGetWithCookies(t *testing.T) {
ts := createGetServer(t)
defer ts.Close()

cookies := []*http.Cookie{
{
Name: "go-resty-1",
Value: "This is cookie 1 value",
},
{
Name: "go-resty-2",
Value: "This is cookie 2 value",
},
}

c := dc()
c.SetHostURL(ts.URL).
SetCookies(cookies)
c.SetHostURL(ts.URL).SetDebug(true)

tu, _ := url.Parse(ts.URL)
c.GetClient().Jar.SetCookies(tu, []*http.Cookie{
Expand All @@ -855,10 +843,26 @@ func TestGetWithCookies(t *testing.T) {
},
})

resp, err := c.R().
SetCookie(&http.Cookie{
resp, err := c.R().SetHeader("Cookie", "").Get("mypage2")
assertError(t, err)
assertEqual(t, http.StatusOK, resp.StatusCode())

// Client cookies
c.SetCookies([]*http.Cookie{
{
Name: "go-resty-1",
Value: "This is cookie 1 value additional append",
Value: "This is cookie 1 value",
},
{
Name: "go-resty-2",
Value: "This is cookie 2 value",
},
})

resp, err = c.R().
SetCookie(&http.Cookie{
Name: "req-go-resty-1",
Value: "This is request cookie 1 value additional append",
}).
Get("mypage2")

Expand Down
2 changes: 2 additions & 0 deletions retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func TestClientRetryGet(t *testing.T) {

resp, err := c.R().Get(ts.URL + "/set-retrycount-test")
assertEqual(t, "", resp.Status())
assertEqual(t, "", resp.Proto())
assertEqual(t, 0, resp.StatusCode())
assertEqual(t, 0, len(resp.Cookies()))
assertNotNil(t, resp.Body())
Expand Down Expand Up @@ -609,6 +610,7 @@ func TestClientRetryCount(t *testing.T) {

resp, err := c.R().Get(ts.URL + "/set-retrycount-test")
assertEqual(t, "", resp.Status())
assertEqual(t, "", resp.Proto())
assertEqual(t, 0, resp.StatusCode())
assertEqual(t, 0, len(resp.Cookies()))
assertNotNil(t, resp.Body())
Expand Down

0 comments on commit 6ad880c

Please sign in to comment.