forked from cloudfoundry/cfhttp
/
cf_http_test.go
53 lines (44 loc) · 1.3 KB
/
cf_http_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
package cf_http_test
import (
"net/http"
"time"
"github.com/cloudfoundry-incubator/cf_http"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("CfHttp", func() {
var timeout time.Duration
BeforeEach(func() {
timeout = 1 * time.Second
})
JustBeforeEach(func() {
cf_http.Initialize(timeout)
})
Describe("NewClient", func() {
It("returns an http client", func() {
client := cf_http.NewClient()
Expect(client.Timeout).To(Equal(timeout))
transport := client.Transport.(*http.Transport)
Expect(transport.Dial).NotTo(BeNil())
Expect(transport.DisableKeepAlives).To(BeFalse())
})
})
Describe("NewCustomTimeoutClient", func() {
It("returns an http client with specified timeout", func() {
client := cf_http.NewCustomTimeoutClient(5 * time.Second)
Expect(client.Timeout).To(Equal(5 * time.Second))
transport := client.Transport.(*http.Transport)
Expect(transport.Dial).NotTo(BeNil())
Expect(transport.DisableKeepAlives).To(BeFalse())
})
})
Describe("NewStreamingClient", func() {
It("returns an http client", func() {
client := cf_http.NewStreamingClient()
Expect(client.Timeout).To(BeZero())
transport := client.Transport.(*http.Transport)
Expect(transport.Dial).NotTo(BeNil())
Expect(transport.DisableKeepAlives).To(BeFalse())
})
})
})