Expect(newCh).To(BeAssignableToTypeOf(msgCh))
			Expect(cap(newCh)).To(Equal(1))
		})

		It("adds the chan to its slice of Message chans for the given cmd", func() {
			newCh := forwarder.EnrollForMsgs("SOMECMD")

			forwarder.MsgChs["SOMECMD"][0] <- &message.Message{}
			Expect(newCh).To(Receive())
		})
	})

	Describe("#StartForwarding", func() {
		var (
			fakeReader *mocks.FakeReader
			rdStrCh    chan string
			fakeCipher *mocks.FakeCipher
		)

		BeforeEach(func() {
			rdStrCh = make(chan string, 1)
			fakeReader = &mocks.FakeReader{RdStrCh: rdStrCh}
			fakeCipher = &mocks.FakeCipher{}
		})

		AfterEach(func() {
			rdStrCh <- "EOF"
		})

		It("reads from the provided ReadStringer, splitting on \\n", func() {
			rdStrCh <- ""
Exemple #2
0
package irc_test

import (
	"github.com/crawsible/crawsibot/irc"
	"github.com/crawsible/crawsibot/irc/message"
	"github.com/crawsible/crawsibot/irc/mocks"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Sender", func() {
	var (
		fakeWriter *mocks.FakeWriter
		fakeCipher *mocks.FakeCipher

		sender *irc.MessageSender
	)

	BeforeEach(func() {
		fakeWriter = &mocks.FakeWriter{}
		fakeCipher = &mocks.FakeCipher{}

		sender = &irc.MessageSender{}
	})

	Describe("#StartSending", func() {
		BeforeEach(func() {
			sender.StartSending(fakeWriter, fakeCipher)
			Eventually(sender.SendCh).ShouldNot(BeNil())
		})