本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/agent/applier/bundlecollection/fakes.FakeBundleCollection.ListErr方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeBundleCollection.ListErr方法的具體用法?Golang FakeBundleCollection.ListErr怎麽用?Golang FakeBundleCollection.ListErr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/agent/applier/bundlecollection/fakes.FakeBundleCollection
的用法示例。
在下文中一共展示了FakeBundleCollection.ListErr方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
job, bundle := buildJob(jobsBc)
fs := fakesys.NewFakeFileSystem()
fs.WriteFileString("/path/to/job/monit", "some conf")
fs.SetGlob("/path/to/job/*.monit", []string{"/path/to/job/subjob.monit"})
bundle.GetDirPath = "/path/to/job"
bundle.GetDirFs = fs
err := applier.Configure(job, 0)
Expect(err).ToNot(HaveOccurred())
Expect(len(jobSupervisor.AddJobArgs)).To(Equal(2))
Expect(jobSupervisor.AddJobArgs[0]).To(Equal(fakejobsuper.AddJobArgs{
Name: job.Name,
Index: 0,
ConfigPath: "/path/to/job/monit",
}))
Expect(jobSupervisor.AddJobArgs[1]).To(Equal(fakejobsuper.AddJobArgs{
Name: job.Name + "_subjob",
Index: 0,
ConfigPath: "/path/to/job/subjob.monit",
}))
})
It("does not require monit script", func() {
job, bundle := buildJob(jobsBc)
fs := fakesys.NewFakeFileSystem()
bundle.GetDirFs = fs
err := applier.Configure(job, 0)
Expect(err).ToNot(HaveOccurred())
Expect(len(jobSupervisor.AddJobArgs)).To(Equal(0))
})
})
Describe("KeepOnly", func() {
It("first disables and then uninstalls jobs that are not in keeponly list", func() {
_, bundle1 := buildJob(jobsBc)
job2, bundle2 := buildJob(jobsBc)
_, bundle3 := buildJob(jobsBc)
job4, bundle4 := buildJob(jobsBc)
jobsBc.ListBundles = []boshbc.Bundle{bundle1, bundle2, bundle3, bundle4}
err := applier.KeepOnly([]models.Job{job4, job2})
Expect(err).ToNot(HaveOccurred())
Expect(bundle1.ActionsCalled).To(Equal([]string{"Disable", "Uninstall"}))
Expect(bundle2.ActionsCalled).To(Equal([]string{}))
Expect(bundle3.ActionsCalled).To(Equal([]string{"Disable", "Uninstall"}))
Expect(bundle4.ActionsCalled).To(Equal([]string{}))
})
It("returns error when bundle collection fails to return list of installed bundles", func() {
jobsBc.ListErr = errors.New("fake-bc-list-error")
err := applier.KeepOnly([]models.Job{})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-bc-list-error"))
})
It("returns error when bundle collection cannot retrieve bundle for keep-only job", func() {
job1, bundle1 := buildJob(jobsBc)
jobsBc.ListBundles = []boshbc.Bundle{bundle1}
jobsBc.GetErr = errors.New("fake-bc-get-error")
err := applier.KeepOnly([]models.Job{job1})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-bc-get-error"))
})
It("returns error when at least one bundle cannot be disabled", func() {
_, bundle1 := buildJob(jobsBc)
jobsBc.ListBundles = []boshbc.Bundle{bundle1}
bundle1.DisableErr = errors.New("fake-bc-disable-error")
err := applier.KeepOnly([]models.Job{})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-bc-disable-error"))
})
It("returns error when at least one bundle cannot be uninstalled", func() {
_, bundle1 := buildJob(jobsBc)
jobsBc.ListBundles = []boshbc.Bundle{bundle1}
bundle1.UninstallErr = errors.New("fake-bc-uninstall-error")
err := applier.KeepOnly([]models.Job{})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-bc-uninstall-error"))
})
})
})
}
示例2: init
//.........這裏部分代碼省略.........
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(blobstore.GetBlobIDs).To(BeNil())
})
})
Context("when package is not installed", func() {
BeforeEach(func() {
bundle.Installed = false
})
It("installs and enables package", func() {
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(bundle.ActionsCalled).To(Equal([]string{"Install", "Enable"}))
})
It("returns error when package enable fails", func() {
bundle.EnableError = errors.New("fake-enable-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-enable-error"))
})
ItInstallsPkg(act)
})
})
})
Describe("KeepOnly", func() {
ItReturnsErrors := func() {
It("returns error when bundle collection fails to return list of installed bundles", func() {
packagesBc.ListErr = errors.New("fake-bc-list-error")
err := applier.KeepOnly([]models.Package{})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-bc-list-error"))
})
It("returns error when bundle collection cannot retrieve bundle for keep-only package", func() {
pkg1, bundle1 := buildPkg(packagesBc)
packagesBc.ListBundles = []boshbc.Bundle{bundle1}
packagesBc.GetErr = errors.New("fake-bc-get-error")
err := applier.KeepOnly([]models.Package{pkg1})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-bc-get-error"))
})
It("returns error when at least one bundle cannot be disabled", func() {
_, bundle1 := buildPkg(packagesBc)
packagesBc.ListBundles = []boshbc.Bundle{bundle1}
bundle1.DisableErr = errors.New("fake-bc-disable-error")
err := applier.KeepOnly([]models.Package{})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-bc-disable-error"))
})
}
Context("when operating on packages as a package owner", func() {
BeforeEach(func() {
applier = NewConcretePackageApplier(packagesBc, true, blobstore, compressor, fs, logger)