本文整理匯總了Golang中bosh/settings/fakes.FakeSettingsService.LoadSettingsError方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSettingsService.LoadSettingsError方法的具體用法?Golang FakeSettingsService.LoadSettingsError怎麽用?Golang FakeSettingsService.LoadSettingsError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/settings/fakes.FakeSettingsService
的用法示例。
在下文中一共展示了FakeSettingsService.LoadSettingsError方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
Describe("bootstrap", func() {
Describe("Run", func() {
var (
inf *fakeinf.FakeInfrastructure
platform *fakeplatform.FakePlatform
dirProvider boshdir.DirectoriesProvider
settingsServiceProvider *fakesettings.FakeSettingsServiceProvider
settingsService *fakesettings.FakeSettingsService
)
BeforeEach(func() {
inf = &fakeinf.FakeInfrastructure{
GetEphemeralDiskPathFound: true,
GetEphemeralDiskPathRealPath: "/dev/sdz",
}
platform = fakeplatform.NewFakePlatform()
dirProvider = boshdir.NewDirectoriesProvider("/var/vcap")
settingsServiceProvider = fakesettings.NewServiceProvider()
settingsService = settingsServiceProvider.NewServiceSettingsService
})
bootstrap := func() (boshsettings.Service, error) {
logger := boshlog.NewLogger(boshlog.LevelNone)
return New(inf, platform, dirProvider, settingsServiceProvider, logger).Run()
}
It("sets up runtime configuration", func() {
_, err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(platform.SetupRuntimeConfigurationWasInvoked).To(BeTrue())
})
It("sets up ssh", func() {
_, err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(inf.SetupSshUsername).To(Equal("vcap"))
})
It("sets up hostname", func() {
settingsService.Settings.AgentID = "foo-bar-baz-123"
_, err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(platform.SetupHostnameHostname).To(Equal("foo-bar-baz-123"))
})
It("returns the settings service", func() {
settingsService, err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(settingsService).To(Equal(settingsService))
Expect(settingsServiceProvider.NewServiceFs).To(Equal(platform.GetFs()))
Expect(settingsServiceProvider.NewServiceDir).To(Equal(dirProvider.BoshDir()))
fetchedSettings, err := settingsServiceProvider.NewServiceFetcher()
Expect(err).NotTo(HaveOccurred())
Expect(fetchedSettings).To(Equal(inf.Settings))
})
It("fetches initial settings", func() {
_, err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(settingsService.SettingsWereLoaded).To(BeTrue())
})
It("returns error from loading initial settings", func() {
settingsService.LoadSettingsError = errors.New("fake-load-error")
_, err := bootstrap()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-load-error"))
})
It("sets up networking", func() {
networks := boshsettings.Networks{
"bosh": boshsettings.Network{},
}
settingsService.Settings.Networks = networks
_, err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(inf.SetupNetworkingNetworks).To(Equal(networks))
})
It("sets up ephemeral disk", func() {
settingsService.Disks = boshsettings.Disks{
Ephemeral: "fake-ephemeral-disk-setting",
}
inf.GetEphemeralDiskPathRealPath = "/dev/sda"
inf.GetEphemeralDiskPathFound = true
_, err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(platform.SetupEphemeralDiskWithPathDevicePath).To(Equal("/dev/sda"))
Expect(inf.GetEphemeralDiskPathDevicePath).To(Equal("fake-ephemeral-disk-setting"))
})
//.........這裏部分代碼省略.........
示例2:
})
})
})
Context("when disk cid cannot be resolved to a device path from infrastructure settings", func() {
BeforeEach(func() {
settingsService.Settings.Disks.Persistent = map[string]string{
"fake-known-disk-cid": "/dev/sdf",
}
})
It("returns error", func() {
_, err := action.Run("fake-unknown-disk-cid")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Persistent disk with volume id 'fake-unknown-disk-cid' could not be found"))
})
})
})
Context("when settings cannot be loaded", func() {
It("returns error", func() {
settingsService.LoadSettingsError = errors.New("fake-load-settings-err")
_, err := action.Run("fake-disk-cid")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-load-settings-err"))
})
})
})
})