-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrequestdata_test.go
68 lines (55 loc) · 1.45 KB
/
requestdata_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package httpclient_test
import (
"net/http"
"net/url"
"strings"
. "github.com/koofr/go-httpclient"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("RequestData", func() {
Describe("Copy", func() {
It("should copy the request", func() {
params := make(url.Values)
params.Set("param", "value")
headers := make(http.Header)
headers.Set("X-Header", "value")
reqValue := map[string]string{
"key": "value",
}
respValue := map[string]string{}
req := &RequestData{
Method: "GET",
Path: "/path",
Params: params,
Headers: headers,
ReqEncoding: EncodingJSON,
ReqValue: reqValue,
ExpectedStatus: []int{200},
IgnoreRedirects: true,
RespEncoding: EncodingXML,
RespValue: &respValue,
RespConsume: true,
}
ok, reqCopy := req.Copy()
Expect(ok).To(BeTrue())
Expect(req).To(Equal(reqCopy))
Expect(&req.Params == &reqCopy.Params).To(BeFalse())
Expect(&req.Headers == &reqCopy.Headers).To(BeFalse())
Expect(&req.ExpectedStatus == &reqCopy.ExpectedStatus).To(BeFalse())
})
})
Describe("CanCopy", func() {
It("should not copy request with reader", func() {
req := &RequestData{
Method: "GET",
Path: "/path",
ReqReader: strings.NewReader("data"),
}
canCopy := req.CanCopy()
Expect(canCopy).To(BeFalse())
ok, _ := req.Copy()
Expect(ok).To(BeFalse())
})
})
})