本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/agent/applier/bundlecollection/fakes.FakeBundleCollection.ListBundles方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeBundleCollection.ListBundles方法的具体用法?Golang FakeBundleCollection.ListBundles怎么用?Golang FakeBundleCollection.ListBundles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/agent/applier/bundlecollection/fakes.FakeBundleCollection
的用法示例。
在下文中一共展示了FakeBundleCollection.ListBundles方法的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
//.........这里部分代码省略.........
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)
})
It("first disables and then uninstalls packages that are not in keeponly list", func() {
_, bundle1 := buildPkg(packagesBc)
pkg2, bundle2 := buildPkg(packagesBc)
_, bundle3 := buildPkg(packagesBc)
pkg4, bundle4 := buildPkg(packagesBc)
packagesBc.ListBundles = []boshbc.Bundle{bundle1, bundle2, bundle3, bundle4}