当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeExitHandler.Exit方法代码示例

本文整理汇总了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)
开发者ID:Klaudit,项目名称:lattice,代码行数:31,代码来源:app_examiner_command_factory_test.go

示例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())
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:ssh_test.go

示例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)
开发者ID:felipeg48,项目名称:lattice,代码行数:31,代码来源:app_examiner_command_factory_test.go


注:本文中的github.com/cloudfoundry-incubator/lattice/ltc/exit_handler/fake_exit_handler.FakeExitHandler.Exit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。