本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/settings/fakes.FakeSettingsService.LoadSettingsError方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSettingsService.LoadSettingsError方法的具體用法?Golang FakeSettingsService.LoadSettingsError怎麽用?Golang FakeSettingsService.LoadSettingsError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/settings/fakes.FakeSettingsService
的用法示例。
在下文中一共展示了FakeSettingsService.LoadSettingsError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
})
})
})
Context("when disk cid cannot be resolved to a device path from infrastructure settings", func() {
BeforeEach(func() {
settingsService.Settings.Disks.Persistent = map[string]interface{}{
"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"))
})
})
})
})
示例2: init
func init() {
Describe("bootstrap", func() {
Describe("Run", func() {
var (
platform *fakeplatform.FakePlatform
dirProvider boshdir.Provider
settingsSource *fakeinf.FakeSettingsSource
settingsService *fakesettings.FakeSettingsService
)
BeforeEach(func() {
platform = fakeplatform.NewFakePlatform()
dirProvider = boshdir.NewProvider("/var/vcap")
settingsSource = &fakeinf.FakeSettingsSource{}
settingsService = &fakesettings.FakeSettingsService{}
})
bootstrap := func() error {
logger := boshlog.NewLogger(boshlog.LevelNone)
return NewBootstrap(platform, dirProvider, settingsService, logger).Run()
}
It("sets up runtime configuration", func() {
err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(platform.SetupRuntimeConfigurationWasInvoked).To(BeTrue())
})
Describe("SSH tunnel setup for registry", func() {
It("returns error without configuring ssh on the platform if getting public key fails", func() {
settingsService.PublicKeyErr = errors.New("fake-get-public-key-err")
err := bootstrap()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-public-key-err"))
Expect(platform.SetupSSHCalled).To(BeFalse())
})
Context("when public key is not empty", func() {
BeforeEach(func() {
settingsService.PublicKey = "fake-public-key"
})
It("gets the public key and sets up ssh via the platform", func() {
err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(platform.SetupSSHPublicKey).To(Equal("fake-public-key"))
Expect(platform.SetupSSHUsername).To(Equal("vcap"))
})
It("returns error if configuring ssh on the platform fails", func() {
platform.SetupSSHErr = errors.New("fake-setup-ssh-err")
err := bootstrap()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-setup-ssh-err"))
})
})
Context("when public key key is empty", func() {
BeforeEach(func() {
settingsSource.PublicKey = ""
})
It("gets the public key and does not setup SSH", func() {
err := bootstrap()
Expect(err).NotTo(HaveOccurred())
Expect(platform.SetupSSHCalled).To(BeFalse())
})
})
})
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("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() {
//.........這裏部分代碼省略.........
示例3:
It("returns the error", func() {
result, err := action.Run(newUpdateSettings)
Expect(err).To(HaveOccurred())
Expect(result).To(BeEmpty())
})
})
It("loads settings", func() {
_, err := action.Run(newUpdateSettings)
Expect(err).ToNot(HaveOccurred())
Expect(settingsService.SettingsWereLoaded).To(BeTrue())
})
Context("when loading the settings fails", func() {
It("returns an error", func() {
settingsService.LoadSettingsError = errors.New("nope")
_, err := action.Run(newUpdateSettings)
Expect(err).To(HaveOccurred())
})
})
Context("when the settings does not contain the disk", func() {
var (
diskAssociation boshsettings.DiskAssociation
newUpdateSettings boshsettings.UpdateSettings
)
BeforeEach(func() {
diskAssociation = boshsettings.DiskAssociation{
Name: "fake-disk-name",
DiskCID: "fake-disk-id",