go func(done chan<- struct{}) { proxy.ProxyChannels(logger, targetConn, newChanChan) done <- struct{}{} }(done) }) Context("when a new channel is opened by the client", func() { BeforeEach(func() { sourceChannel.ReadReturns(0, io.EOF) targetChannel.ReadReturns(0, io.EOF) newChan.ChannelTypeReturns("test") newChan.ExtraDataReturns([]byte("extra-data")) newChan.AcceptReturns(sourceChannel, sourceReqChan, nil) targetConn.OpenChannelReturns(targetChannel, targetReqChan, nil) newChanChan <- newChan }) AfterEach(func() { close(newChanChan) }) It("forwards the NewChannel request to the target", func() { Eventually(targetConn.OpenChannelCallCount).Should(Equal(1)) Consistently(targetConn.OpenChannelCallCount).Should(Equal(1)) channelType, extraData := targetConn.OpenChannelArgsForCall(0) Expect(channelType).To(Equal("test")) Expect(extraData).To(Equal([]byte("extra-data")))