Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiante committed Mar 3, 2024
1 parent 9152f3d commit 2c5a4a7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions client_test.go
Expand Up @@ -1069,3 +1069,29 @@ func TestUnixSocket(t *testing.T) {
assertNil(t, err)
assertEqual(t, "Hello resty client from a server running on endpoint /hello!", res.String())
}

func TestClone(t *testing.T) {
parent := New()

// set a non-interface field
parent.SetBaseURL("http://localhost")

// set an interface field
parent.UserInfo = &User{
Username: "parent",
}

clone := parent.Clone()
// update value of non-interface type - change will only happen on clone
clone.SetBaseURL("https://local.host")
// update value of interface type - change will also happen on parent
clone.UserInfo.Username = "clone"

// asert non-interface type
assertEqual(t, "http://localhost", parent.BaseURL)
assertEqual(t, "https://local.host", clone.BaseURL)

// assert interface type
assertEqual(t, "clone", parent.UserInfo.Username)
assertEqual(t, "clone", clone.UserInfo.Username)
}

0 comments on commit 2c5a4a7

Please sign in to comment.