Skip to content

Commit

Permalink
fix: add uncover test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tttturtle-russ committed Sep 12, 2024
1 parent 15f9912 commit 627af81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,10 @@ func TestRequestClone(t *testing.T) {
parent.SetHeader("X-Header", "parent")
// set an interface value
parent.SetBasicAuth("parent", "")
parent.bodyBuf = acquireBuffer()
parent.bodyBuf.WriteString("parent")
parent.RawRequest = &http.Request{}

clone := parent.Clone(context.Background())

// assume parent request is used
Expand All @@ -2206,6 +2210,8 @@ func TestRequestClone(t *testing.T) {
clone.SetHeader("X-Header", "clone")
// update value of interface type - change will only happen on clone
clone.UserInfo.Username = "clone"
clone.bodyBuf.Reset()
clone.bodyBuf.WriteString("clone")

// assert non-interface type
assertEqual(t, "http://localhost.clone", clone.URL)
Expand All @@ -2220,9 +2226,11 @@ func TestRequestClone(t *testing.T) {
// assert interface type
assertEqual(t, "parent", parent.UserInfo.Username)
assertEqual(t, "clone", clone.UserInfo.Username)
assertEqual(t, "", parent.bodyBuf.String())
assertEqual(t, "clone", clone.bodyBuf.String())

// parent request should have raw request while clone should not
assertNil(t, clone.RawRequest)
assertNotNil(t, clone.RawRequest)
assertNotNil(t, parent.RawRequest)
assertNotEqual(t, parent.RawRequest, clone.RawRequest)

Expand Down
2 changes: 2 additions & 0 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,7 @@ func TestCloneURLValues(t *testing.T) {
v.Add("qux", "quux")

c := cloneURLValues(v)
nilUrl := cloneURLValues(nil)
assertEqual(t, v, c)
assertNil(t, nilUrl)
}

0 comments on commit 627af81

Please sign in to comment.