Пример #1
0
			mockProtocol.On(`Close`).Return(errors.New(`close failure`))
			Expect(client.Close()).NotTo(Succeed())
		})

		It("should return an error on double-close", func() {
			mockProtocol.On(`Close`).Return(nil)
			Expect(client.Close()).To(Succeed())
			Expect(client.Close()).To(Equal(common.ErrClosed))
		})

		It("should publish an EventNewLocation on discovering a location", func(done Done) {
			mockLocation.Group.On(`ID`).Return(locationID)
			event := common.EventNewLocation{Location: mockLocation}
			ch := make(chan interface{})
			go func() {
				evt := <-clientSubscription.Events()
				ch <- evt
			}()
			_ = protocolSubscription.Write(event)
			Expect(<-ch).To(Equal(event))
			close(done)
		})

		It("should publish an EventNewGroup on discovering a group", func(done Done) {
			mockGroup.On(`ID`).Return(groupID)
			event := common.EventNewGroup{Group: mockGroup}
			ch := make(chan interface{})
			go func() {
				evt := <-clientSubscription.Events()
				ch <- evt
			}()