var clients []clientpool.Client BeforeEach(func() { clients = []clientpool.Client{ newMockClient(), newMockClient(), } close(mockClientCreator.CreateClientOutput.err) mockClientCreator.CreateClientOutput.client <- clients[0] mockClientCreator.CreateClientOutput.client <- clients[1] }) It("creates a client for each address", func() { Expect(pool.Clients()).To(HaveLen(0)) clients := pool.SetAddresses(addresses) Expect(clients).To(Equal(2)) Eventually(mockClientCreator.CreateClientInput.url).Should(Receive(Equal(addresses[0]))) Eventually(mockClientCreator.CreateClientInput.url).Should(Receive(Equal(addresses[1]))) Expect(pool.Clients()).To(HaveLen(2)) }) }) Context("with failed client creation", func() { var err error BeforeEach(func() { err = errors.New("failed client creation")