本文整理汇总了Golang中github.com/cloudfoundry-incubator/diego-ssh/test_helpers/fake_net.FakeListener类的典型用法代码示例。如果您正苦于以下问题:Golang FakeListener类的具体用法?Golang FakeListener怎么用?Golang FakeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeListener类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
It("sends keep alive messages at the expected interval", func() {
times := <-timesCh
Expect(times[2]).To(BeTemporally("~", times[0].Add(200*time.Millisecond), 100*time.Millisecond))
})
})
})
Describe("LocalPortForward", func() {
var (
opts *options.SSHOptions
localForwardError error
echoAddress string
echoListener *fake_net.FakeListener
echoHandler *fake_server.FakeConnectionHandler
echoServer *server.Server
localAddress string
realLocalListener net.Listener
fakeLocalListener *fake_net.FakeListener
)
BeforeEach(func() {
logger := lagertest.NewTestLogger("test")
var err error
realLocalListener, err = net.Listen("tcp", "127.0.0.1:0")
Expect(err).NotTo(HaveOccurred())
localAddress = realLocalListener.Addr().String()
示例2:
srv = server.NewServer(logger, address, handler)
srv.SetListener(fakeListener)
})
Context("when a listener has already been set", func() {
It("returns an error", func() {
listener := &fake_net.FakeListener{}
err := srv.SetListener(listener)
Expect(err).To(MatchError("Listener has already been set"))
})
})
})
Describe("Serve", func() {
var fakeListener *fake_net.FakeListener
var fakeConn *fake_net.FakeConn
BeforeEach(func() {
fakeListener = &fake_net.FakeListener{}
fakeConn = &fake_net.FakeConn{}
connectionCh := make(chan net.Conn, 1)
connectionCh <- fakeConn
fakeListener.AcceptStub = func() (net.Conn, error) {
cx := connectionCh
select {
case conn := <-cx:
return conn, nil
default: