本文整理匯總了Golang中github.com/cloudfoundry/bosh-utils/system/fakes.FakeCmdRunner.AddProcess方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeCmdRunner.AddProcess方法的具體用法?Golang FakeCmdRunner.AddProcess怎麽用?Golang FakeCmdRunner.AddProcess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-utils/system/fakes.FakeCmdRunner
的用法示例。
在下文中一共展示了FakeCmdRunner.AddProcess方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
oldSpec := exampleSpec()
newSpec := exampleSpec()
s := newSpec.PackageSpecs["foo"]
s.Sha1 = "foo_updated_sha1"
newSpec.PackageSpecs["foo"] = s
s = newSpec.PackageSpecs["bar"]
s.Sha1 = "bar_updated_sha1"
newSpec.PackageSpecs["bar"] = s
params = NewUpdateParams(oldSpec, newSpec)
})
It("runs drain script", func() {
runner.AddProcess("/fake/script job_unchanged hash_unchanged bar foo",
&fakesys.FakeProcess{WaitResult: boshsys.Result{Stdout: "1"}})
err := script.Run()
Expect(err).ToNot(HaveOccurred())
expectedCmd := boshsys.Command{
Name: "/fake/script",
Args: []string{"job_unchanged", "hash_unchanged", "bar", "foo"},
Env: map[string]string{
"PATH": "/usr/sbin:/usr/bin:/sbin:/bin",
"BOSH_JOB_STATE": "{\"persistent_disk\":42}",
"BOSH_JOB_NEXT_STATE": "{\"persistent_disk\":42}",
},
}
Expect(len(runner.RunComplexCommands)).To(Equal(1))
示例2:
Describe("Run", func() {
Context("when apply spec is successfully retrieved", func() {
Context("when current agent has a job spec template", func() {
BeforeEach(func() {
currentSpec := boshas.V1ApplySpec{}
currentSpec.JobSpec.Template = "fake-job-name"
specService.Spec = currentSpec
})
Context("when errand script exits with non-0 exit code (execution of script is ok)", func() {
BeforeEach(func() {
cmdRunner.AddProcess("/fake-jobs-dir/fake-job-name/bin/run", &fakesys.FakeProcess{
WaitResult: boshsys.Result{
Stdout: "fake-stdout",
Stderr: "fake-stderr",
ExitStatus: 0,
},
})
})
It("returns errand result without error after running an errand", func() {
result, err := action.Run()
Expect(err).ToNot(HaveOccurred())
Expect(result).To(Equal(
ErrandResult{
Stdout: "fake-stdout",
Stderr: "fake-stderr",
ExitStatus: 0,
},
))
示例3:
ExitStatus: 0,
Sticky: true,
})
certManager = cert.NewUbuntuCertManager(fakeFs, fakeCmdRunner, 1, log)
fakeResult = boshsys.Result{
Stdout: "",
Stderr: "",
ExitStatus: 0,
Error: nil,
}
fakeProcess1 = &fakesys.FakeProcess{WaitResult: fakeResult}
fakeProcess2 = &fakesys.FakeProcess{WaitResult: fakeResult}
fakeProcess3 = &fakesys.FakeProcess{WaitResult: fakeResult}
fakeCmdRunner.AddProcess("/usr/sbin/update-ca-certificates -f", fakeProcess1)
fakeCmdRunner.AddProcess("/usr/sbin/update-ca-certificates -f", fakeProcess2)
fakeCmdRunner.AddProcess("/usr/sbin/update-ca-certificates -f", fakeProcess3)
})
SharedLinuxCertManagerExamples("/usr/local/share/ca-certificates", "/usr/sbin/update-ca-certificates")
It("updates certs", func() {
err := certManager.UpdateCertificates(cert1)
Expect(fakeProcess1.Waited).To(BeTrue())
Expect(fakeProcess1.TerminatedNicely).To(BeFalse())
Expect(err).ToNot(HaveOccurred())
})