本文整理汇总了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()
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:ssh_test.go
示例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:
开发者ID:benjaminharnett,项目名称:diego-ssh,代码行数:30,代码来源:server_test.go
注:本文中的github.com/cloudfoundry-incubator/diego-ssh/test_helpers/fake_net.FakeListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论