當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeSettingsService.Disks方法代碼示例

本文整理匯總了Golang中bosh/settings/fakes.FakeSettingsService.Disks方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSettingsService.Disks方法的具體用法?Golang FakeSettingsService.Disks怎麽用?Golang FakeSettingsService.Disks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bosh/settings/fakes.FakeSettingsService的用法示例。


在下文中一共展示了FakeSettingsService.Disks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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"))
			})
//.........這裏部分代碼省略.........
開發者ID:Jane4PKU,項目名稱:bosh,代碼行數:101,代碼來源:bootstrap_test.go


注:本文中的bosh/settings/fakes.FakeSettingsService.Disks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。