本文整理汇总了Golang中github.com/cloudfoundry-incubator/lattice/ltc/exit_handler/fake_exit_handler.FakeExitHandler.Exit方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeExitHandler.Exit方法的具体用法?Golang FakeExitHandler.Exit怎么用?Golang FakeExitHandler.Exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/lattice/ltc/exit_handler/fake_exit_handler.FakeExitHandler
的用法示例。
在下文中一共展示了FakeExitHandler.Exit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
test_helpers.ExecuteCommandWithArgs(visualizeCommand, []string{})
Expect(outputBuffer).To(test_helpers.Say("Error visualizing: The list was lost"))
Expect(outputBuffer).To(test_helpers.Say(cursor.ClearToEndOfLine()))
Expect(outputBuffer).To(test_helpers.SayNewLine())
// TODO: this should return non-zero, but it's shared with refresh view
// which should continue to retry in the event on an error and not exit
})
})
Context("when a rate flag is provided", func() {
var closeChan chan struct{}
AfterEach(func() {
go fakeExitHandler.Exit(exit_codes.SigInt)
Eventually(closeChan).Should(BeClosed())
})
It("dynamically displays the visualization", func() {
setNumberOfRunningInstances := func(count int) {
fakeAppExaminer.ListCellsReturns([]app_examiner.CellInfo{app_examiner.CellInfo{CellID: "cell-0", RunningInstances: count}, app_examiner.CellInfo{CellID: "cell-1", RunningInstances: count, Missing: true}}, nil)
}
setNumberOfRunningInstances(0)
closeChan = test_helpers.AsyncExecuteCommandWithArgs(visualizeCommand, []string{"--rate", "2s"})
Eventually(outputBuffer).Should(test_helpers.SayLine("cell-0: " + colors.Red("empty") + cursor.ClearToEndOfLine()))
Eventually(outputBuffer).Should(test_helpers.SayLine("cell-1" + colors.Red("[MISSING]") + ": " + cursor.ClearToEndOfLine()))
setNumberOfRunningInstances(2)
示例2:
waitChan := make(chan struct{})
fakeSession.ShellStub = func() error {
waitChan <- struct{}{}
waitChan <- struct{}{}
return nil
}
Expect(appSSH.Connect("some-app-name", 100, config)).To(Succeed())
go func() {
appSSH.Shell("", true)
}()
<-waitChan
fakeExitHandler.Exit(123)
Eventually(fakeTerm.RestoreTerminalCallCount).Should(Equal(1))
actualFD, actualState := fakeTerm.RestoreTerminalArgsForCall(0)
Expect(actualFD).To(Equal(os.Stdin.Fd()))
Expect(reflect.ValueOf(actualState).Pointer()).To(Equal(reflect.ValueOf(state).Pointer()))
<-waitChan
})
Context("when we fail to set the raw terminal", func() {
It("does not restore the terminal at the end", func() {
fakeTerm.SetRawTerminalReturns(nil, errors.New("some error"))
Expect(appSSH.Connect("some-app-name", 100, config)).To(Succeed())
Expect(appSSH.Shell("", true)).To(Succeed())
示例3:
test_helpers.ExecuteCommandWithArgs(visualizeCommand, []string{})
Expect(outputBuffer).To(test_helpers.Say("Error visualizing: The list was lost"))
Expect(outputBuffer).To(test_helpers.Say(cursor.ClearToEndOfLine()))
Expect(outputBuffer).To(test_helpers.SayNewLine())
// TODO: this should return non-zero, but it's shared with refresh view
// which should continue to retry in the event on an error and not exit
})
})
Context("when a rate flag is provided", func() {
var closeChan chan struct{}
AfterEach(func() {
go fakeExitHandler.Exit(exit_codes.Signal)
Eventually(closeChan).Should(BeClosed())
})
It("dynamically displays the visualization", func() {
setNumberOfRunningInstances := func(count int) {
fakeAppExaminer.ListCellsReturns([]app_examiner.CellInfo{app_examiner.CellInfo{CellID: "cell-0", RunningInstances: count}, app_examiner.CellInfo{CellID: "cell-1", RunningInstances: count, Missing: true}}, nil)
}
setNumberOfRunningInstances(0)
closeChan = test_helpers.AsyncExecuteCommandWithArgs(visualizeCommand, []string{"--rate", "2s"})
Eventually(outputBuffer).Should(test_helpers.SayLine("cell-0: " + colors.Red("empty") + cursor.ClearToEndOfLine()))
Eventually(outputBuffer).Should(test_helpers.SayLine("cell-1" + colors.Red("[MISSING]") + ": " + cursor.ClearToEndOfLine()))
setNumberOfRunningInstances(2)