import ( "bytes" "code.google.com/p/gogoprotobuf/proto" "errors" "github.com/cloudfoundry-incubator/dropsonde/emitter" "github.com/cloudfoundry-incubator/dropsonde/emitter/fake" "github.com/cloudfoundry-incubator/dropsonde/events" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "log" "time" ) var _ = Describe("HeartbeatEmitter", func() { var ( wrappedEmitter *fake.FakeByteEmitter origin = "testHeartbeatEmitter/0" ) BeforeEach(func() { emitter.HeartbeatInterval = 10 * time.Millisecond wrappedEmitter = fake.NewFakeByteEmitter() }) Describe("NewHeartbeatEmitter", func() { It("requires non-nil args", func() { hbEmitter, err := emitter.NewHeartbeatEmitter(nil, origin) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(Equal("wrappedEmitter is nil")) Expect(hbEmitter).To(BeNil()) })
import ( "errors" "github.com/cloudfoundry-incubator/dropsonde/emitter" "github.com/cloudfoundry-incubator/dropsonde/emitter/fake" "github.com/cloudfoundry-incubator/dropsonde/events" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func getHeartbeatEvent(ie emitter.InstrumentedEmitter) *events.Heartbeat { return ie.GetHeartbeatEvent().(*events.Heartbeat) } var _ = Describe("InstrumentedEmitter", func() { var fakeEmitter *fake.FakeByteEmitter var instrumentedEmitter emitter.InstrumentedEmitter BeforeEach(func() { fakeEmitter = fake.NewFakeByteEmitter() instrumentedEmitter, _ = emitter.NewInstrumentedEmitter(fakeEmitter) }) Describe("Delegators", func() { It("delegates Close() to the concreteEmitter", func() { instrumentedEmitter.Close() Eventually(fakeEmitter.IsClosed).Should(BeTrue()) }) })