コード例 #1
0
		udpClientCreator = clientpool.NewUDPClientCreator(logger)
	})

	Describe("CreateClient", func() {
		var (
			client    clientpool.Client
			createErr error
		)

		JustBeforeEach(func() {
			client, createErr = udpClientCreator.CreateClient(address)
		})
		It("makes clients", func() {
			Expect(createErr).ToNot(HaveOccurred())
			Expect(client.Address()).To(Equal(address))
			Expect(client.Scheme()).To(Equal("udp"))
		})

		Context("with an invalid address", func() {
			BeforeEach(func() {
				address = "I am definitely not an address"
			})

			It("returns an error and a nil client", func() {
				Expect(createErr).To(HaveOccurred())
				Expect(client).To(BeNil())
			})
		})

		Context("with a returned client", func() {
			var client clientpool.Client
コード例 #2
0
ファイル: tlsclient_test.go プロジェクト: lyuyun/loggregator
		Context("when the connect fails", func() {
			BeforeEach(func() {
				tlsListener.Close()
			})

			It("returns a client", func() {
				Expect(client).NotTo(BeNil())
				Consistently(connChan).ShouldNot(Receive())
			})
		})
	})

	Describe("Scheme", func() {
		It("returns tls", func() {
			Expect(client.Scheme()).To(Equal("tls"))
		})
	})

	Describe("Address", func() {
		It("returns the address", func() {
			Expect(client.Address()).To(Equal(tlsListener.Addr().String()))
		})
	})

	Describe("Writing data", func() {
		var conn net.Conn

		JustBeforeEach(func() {
			Eventually(connChan).Should(Receive(&conn))
			Expect(conn).NotTo(BeNil())