本文整理匯總了Golang中bosh/agent/applier/bundlecollection/fakes.FakeBundleCollection.ListBundles方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeBundleCollection.ListBundles方法的具體用法?Golang FakeBundleCollection.ListBundles怎麽用?Golang FakeBundleCollection.ListBundles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/agent/applier/bundlecollection/fakes.FakeBundleCollection
的用法示例。
在下文中一共展示了FakeBundleCollection.ListBundles方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
ItInstallsJob(act)
ItUpdatesPackages(act)
})
})
})
Describe("Configure", func() {
It("adds job to the job supervisor", func() {
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(2).To(Equal(len(jobSupervisor.AddJobArgs)))
firstArgs := fakejobsuper.AddJobArgs{
Name: job.Name,
Index: 0,
ConfigPath: "/path/to/job/monit",
}
secondArgs := fakejobsuper.AddJobArgs{
Name: job.Name + "_subjob",
Index: 0,
ConfigPath: "/path/to/job/subjob.monit",
}
Expect(firstArgs).To(Equal(jobSupervisor.AddJobArgs[0]))
Expect(secondArgs).To(Equal(jobSupervisor.AddJobArgs[1]))
})
})
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}