-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdropsonde_test.go
46 lines (35 loc) · 1.18 KB
/
dropsonde_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
package dropsonde_test
import (
"net/http"
"reflect"
"github.com/cloudfoundry/dropsonde"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Autowire", func() {
Describe("Initialize", func() {
It("resets the HTTP default transport to be instrumented", func() {
dropsonde.InitializeWithEmitter(&dropsonde.NullEventEmitter{})
Expect(reflect.TypeOf(http.DefaultTransport).Elem().Name()).To(Equal("instrumentedCancelableRoundTripper"))
})
})
Describe("CreateDefaultEmitter", func() {
Context("with origin missing", func() {
It("returns a NullEventEmitter", func() {
err := dropsonde.Initialize("localhost:2343", "")
Expect(err).To(HaveOccurred())
emitter := dropsonde.AutowiredEmitter()
Expect(emitter).ToNot(BeNil())
Expect(emitter).To(Equal(dropsonde.DefaultEmitter))
nullEmitter := &dropsonde.NullEventEmitter{}
Expect(emitter).To(BeAssignableToTypeOf(nullEmitter))
})
})
})
})
type FakeHandler struct{}
func (fh FakeHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {}
type FakeRoundTripper struct{}
func (frt FakeRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return nil, nil
}