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


Golang FakeScript.RunCallCount方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/agent/script/fakes.FakeScript.RunCallCount方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeScript.RunCallCount方法的具体用法?Golang FakeScript.RunCallCount怎么用?Golang FakeScript.RunCallCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/bosh-agent/agent/script/fakes.FakeScript的用法示例。


在下文中一共展示了FakeScript.RunCallCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

								if jobName == "foo" {
									return fooScript
								} else if jobName == "bar" {
									return barScript
								} else {
									panic("Non-matching update drain script created")
								}
							}

							parallelScript.RunReturns(nil)

							value, err := act()
							Expect(err).ToNot(HaveOccurred())
							Expect(value).To(Equal(0))

							Expect(parallelScript.RunCallCount()).To(Equal(1))
							Expect(jobScriptProvider.NewParallelScriptCallCount()).To(Equal(1))

							scriptName, scripts := jobScriptProvider.NewParallelScriptArgsForCall(0)
							Expect(scriptName).To(Equal("drain"))
							Expect(scripts).To(Equal([]boshscript.Script{fooScript, barScript}))
						})

						It("returns an error when parallel script fails", func() {
							parallelScript.RunReturns(errors.New("fake-error"))

							value, err := act()
							Expect(err).To(HaveOccurred())
							Expect(err.Error()).To(ContainSubstring("fake-error"))
							Expect(value).To(Equal(0))
						})
开发者ID:nimbus-cloud,项目名称:bosh-agent,代码行数:31,代码来源:drain_test.go

示例2:

			BeforeEach(func() {
				existingScript = &fakescript.FakeScript{}
				existingScript.TagReturns("fake-job-1")
				existingScript.PathReturns("path/to/script1")
				existingScript.ExistsReturns(true)
				scripts = append(scripts, existingScript)
			})

			It("executes the script and succeeds", func() {
				existingScript.RunReturns(nil)

				err := parallelScript.Run()
				Expect(err).ToNot(HaveOccurred())

				Expect(existingScript.RunCallCount()).To(Equal(1))
			})

			It("gives an error when script fails", func() {
				existingScript.RunReturns(errors.New("fake-error"))

				err := parallelScript.Run()
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(Equal("1 of 1 run-me scripts failed. Failed Jobs: fake-job-1."))

				Expect(existingScript.RunCallCount()).To(Equal(1))
			})
		})

		Context("when script does not exist", func() {
			var nonExistingScript *fakescript.FakeScript
开发者ID:nimbus-cloud,项目名称:bosh-agent,代码行数:30,代码来源:parallel_script_test.go


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