本文整理匯總了Golang中bosh/agent/applier/packageapplier/fakes.FakePackageApplier.ApplyError方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakePackageApplier.ApplyError方法的具體用法?Golang FakePackageApplier.ApplyError怎麽用?Golang FakePackageApplier.ApplyError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/agent/applier/packageapplier/fakes.FakePackageApplier
的用法示例。
在下文中一共展示了FakePackageApplier.ApplyError方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
binTest2Stats = fs.GetFileTestStat("/fake-tmp-dir/fake-path-in-archive/bin/test2")
configTestStats = fs.GetFileTestStat("/fake-tmp-dir/fake-path-in-archive/config/test")
}
err := act()
Expect(err).ToNot(HaveOccurred())
// bin files are executable
Expect(int(binTest1Stats.FileMode)).To(Equal(0755))
Expect(int(binTest2Stats.FileMode)).To(Equal(0755))
// non-bin files are not made executable
Expect(int(configTestStats.FileMode)).ToNot(Equal(0755))
})
}
ItUpdatesPackages := func(act func() error) {
var packageApplier *fakepa.FakePackageApplier
BeforeEach(func() {
packageApplier = fakepa.NewFakePackageApplier()
packageApplierProvider.JobSpecificPackageAppliers[job.Name] = packageApplier
})
It("applies each package that job depends on and then cleans up packages", func() {
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(packageApplier.ActionsCalled).To(Equal([]string{"Apply", "Apply", "KeepOnly"}))
Expect(len(packageApplier.AppliedPackages)).To(Equal(2)) // present
Expect(packageApplier.AppliedPackages).To(Equal(job.Packages))
})
It("returns error when applying package that job depends on fails", func() {
packageApplier.ApplyError = errors.New("fake-apply-err")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-apply-err"))
})
It("keeps only currently required packages but does not completely uninstall them", func() {
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(len(packageApplier.KeptOnlyPackages)).To(Equal(2)) // present
Expect(packageApplier.KeptOnlyPackages).To(Equal(job.Packages))
})
It("returns error when keeping only currently required packages fails", func() {
packageApplier.KeepOnlyErr = errors.New("fake-keep-only-err")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-keep-only-err"))
})
}
Describe("Prepare", func() {
act := func() error { return applier.Prepare(job) }
It("return an error if getting file bundle fails", func() {
jobsBc.GetErr = errors.New("fake-get-bundle-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-bundle-error"))
})
示例2: init
func init() {
Describe("concreteApplier", func() {
var (
jobApplier *fakeja.FakeJobApplier
packageApplier *fakepa.FakePackageApplier
logRotateDelegate *FakeLogRotateDelegate
jobSupervisor *fakejobsuper.FakeJobSupervisor
applier Applier
)
BeforeEach(func() {
jobApplier = fakeja.NewFakeJobApplier()
packageApplier = fakepa.NewFakePackageApplier()
logRotateDelegate = &FakeLogRotateDelegate{}
jobSupervisor = fakejobsuper.NewFakeJobSupervisor()
applier = NewConcreteApplier(
jobApplier,
packageApplier,
logRotateDelegate,
jobSupervisor,
boshdirs.NewDirectoriesProvider("/fake-base-dir"),
)
})
It("removes all jobs", func() {
err := applier.Apply(&fakeas.FakeApplySpec{})
Expect(err).ToNot(HaveOccurred())
Expect(jobSupervisor.RemovedAllJobs).To(BeTrue())
})
It("removes all previous jobs before starting to apply jobs", func() {
// force remove all error
jobSupervisor.RemovedAllJobsErr = errors.New("fake-remove-all-jobs-error")
job := buildJob()
applier.Apply(&fakeas.FakeApplySpec{JobResults: []models.Job{job}})
// check that jobs were not applied before removing all other jobs
Expect(jobApplier.AppliedJobs).To(Equal([]models.Job{}))
})
It("returns error if removing all jobs fails", func() {
jobSupervisor.RemovedAllJobsErr = errors.New("fake-remove-all-jobs-error")
err := applier.Apply(&fakeas.FakeApplySpec{})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-remove-all-jobs-error"))
})
It("apply applies jobs", func() {
job := buildJob()
err := applier.Apply(&fakeas.FakeApplySpec{JobResults: []models.Job{job}})
Expect(err).ToNot(HaveOccurred())
Expect(jobApplier.AppliedJobs).To(Equal([]models.Job{job}))
})
It("apply errs when applying jobs errs", func() {
job := buildJob()
jobApplier.ApplyError = errors.New("fake-apply-job-error")
err := applier.Apply(&fakeas.FakeApplySpec{JobResults: []models.Job{job}})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-apply-job-error"))
})
It("apply applies packages", func() {
pkg1 := buildPackage()
pkg2 := buildPackage()
err := applier.Apply(&fakeas.FakeApplySpec{PackageResults: []models.Package{pkg1, pkg2}})
Expect(err).ToNot(HaveOccurred())
Expect(packageApplier.AppliedPackages).To(Equal([]models.Package{pkg1, pkg2}))
})
It("apply errs when applying packages errs", func() {
pkg := buildPackage()
packageApplier.ApplyError = errors.New("fake-apply-package-error")
err := applier.Apply(&fakeas.FakeApplySpec{PackageResults: []models.Package{pkg}})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-apply-package-error"))
})
It("apply configures jobs", func() {
job1 := models.Job{Name: "fake-job-name-1", Version: "fake-version-name-1"}
job2 := models.Job{Name: "fake-job-name-2", Version: "fake-version-name-2"}
jobs := []models.Job{job1, job2}
err := applier.Apply(&fakeas.FakeApplySpec{JobResults: jobs})
Expect(err).ToNot(HaveOccurred())
Expect(jobApplier.ConfiguredJobs).To(Equal([]models.Job{job2, job1}))
Expect(jobApplier.ConfiguredJobIndices).To(Equal([]int{0, 1}))
Expect(jobSupervisor.Reloaded).To(BeTrue())
})
//.........這裏部分代碼省略.........