本文整理汇总了Golang中github.com/cloudfoundry-incubator/diego-ssh/test_helpers/fake_net.FakeConn类的典型用法代码示例。如果您正苦于以下问题:Golang FakeConn类的具体用法?Golang FakeConn怎么用?Golang FakeConn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeConn类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1:
BeforeEach(func() {
daemonAuthenticator.AuthenticateReturns(nil, errors.New("go away"))
})
It("closes the connection", func() {
Eventually(client.Wait).Should(Equal(io.EOF))
})
It("logs the failure", func() {
Eventually(logger).Should(gbytes.Say(`new-client-conn.handshake-failed`))
})
})
})
Context("when HandleConnection returns", func() {
var fakeServerConnection *fake_net.FakeConn
BeforeEach(func() {
proxySSHConfig.NoClientAuth = true
daemonSSHConfig.NoClientAuth = true
})
JustBeforeEach(func() {
clientNetConn, serverNetConn := test_helpers.Pipe()
fakeServerConnection = &fake_net.FakeConn{}
fakeServerConnection.ReadStub = serverNetConn.Read
fakeServerConnection.WriteStub = serverNetConn.Write
fakeServerConnection.CloseStub = serverNetConn.Close
go sshProxy.HandleConnection(fakeServerConnection)
开发者ID:sykesm,项目名称:diego-ssh,代码行数:31,代码来源:proxy_test.go
示例2:
fakeLocalListener.AcceptReturns(nil, errors.New("not accepting and connections"))
})
It("closes the listener when the client is closed", func() {
Eventually(fakeListenerFactory.ListenCallCount).Should(Equal(1))
Eventually(fakeLocalListener.AcceptCallCount).Should(Equal(1))
originalCloseCount := fakeLocalListener.CloseCallCount()
err := secureShell.Close()
Expect(err).NotTo(HaveOccurred())
Expect(fakeLocalListener.CloseCallCount()).Should(Equal(originalCloseCount + 1))
})
})
Context("when accept fails", func() {
var fakeConn *fake_net.FakeConn
BeforeEach(func() {
fakeConn = &fake_net.FakeConn{}
fakeConn.ReadReturns(0, io.EOF)
fakeListenerFactory.ListenReturns(fakeLocalListener, nil)
})
Context("with a permanent error", func() {
BeforeEach(func() {
fakeLocalListener.AcceptReturns(nil, errors.New("boom"))
})
It("stops trying to accept connections", func() {
Eventually(fakeLocalListener.AcceptCallCount).Should(Equal(1))
Consistently(fakeLocalListener.AcceptCallCount).Should(Equal(1))
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:ssh_test.go
示例3:
logger lager.Logger
sshd *daemon.Daemon
serverSSHConfig *ssh.ServerConfig
)
BeforeEach(func() {
logger = lagertest.NewTestLogger("test")
serverSSHConfig = &ssh.ServerConfig{
NoClientAuth: true,
}
serverSSHConfig.AddHostKey(TestHostKey)
})
Describe("HandleConnection", func() {
var fakeConn *fake_net.FakeConn
Context("when the function returns", func() {
BeforeEach(func() {
fakeConn = &fake_net.FakeConn{}
fakeConn.ReadReturns(0, errors.New("oops"))
sshd = daemon.New(logger, serverSSHConfig, nil, nil)
})
It("closes the connection", func() {
sshd.HandleConnection(fakeConn)
Expect(fakeConn.CloseCallCount()).To(BeNumerically(">=", 1))
})
})
开发者ID:benjaminharnett,项目名称:diego-ssh,代码行数:30,代码来源:daemon_test.go
注:本文中的github.com/cloudfoundry-incubator/diego-ssh/test_helpers/fake_net.FakeConn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论