本文整理匯總了Golang中bosh/platform/fakes.NewFakePlatform函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewFakePlatform函數的具體用法?Golang NewFakePlatform怎麽用?Golang NewFakePlatform使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewFakePlatform函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
Describe("Testing with Ginkgo", func() {
It("list disk should be synchronous", func() {
settings := &fakesettings.FakeSettingsService{}
platform := fakeplatform.NewFakePlatform()
action := NewListDisk(settings, platform)
assert.False(GinkgoT(), action.IsAsynchronous())
})
It("list disk run", func() {
settings := &fakesettings.FakeSettingsService{
Disks: boshsettings.Disks{
Persistent: map[string]string{
"volume-1": "/dev/sda",
"volume-2": "/dev/sdb",
"volume-3": "/dev/sdc",
},
},
}
platform := fakeplatform.NewFakePlatform()
platform.MountedDevicePaths = []string{"/dev/sdb", "/dev/sdc"}
action := NewListDisk(settings, platform)
value, err := action.Run()
assert.NoError(GinkgoT(), err)
boshassert.MatchesJsonString(GinkgoT(), value, `["volume-2","volume-3"]`)
})
})
}
示例2: init
func init() {
Describe("Testing with Ginkgo", func() {
It("unmount disk should be asynchronous", func() {
platform := fakeplatform.NewFakePlatform()
action := buildUnmountDiskAction(platform)
Expect(action.IsAsynchronous()).To(BeTrue())
})
It("is not persistent", func() {
platform := fakeplatform.NewFakePlatform()
action := buildUnmountDiskAction(platform)
Expect(action.IsPersistent()).To(BeFalse())
})
It("unmount disk when the disk is mounted", func() {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = true
unmountDisk := buildUnmountDiskAction(platform)
result, err := unmountDisk.Run("vol-123")
Expect(err).ToNot(HaveOccurred())
boshassert.MatchesJSONString(GinkgoT(), result, `{"message":"Unmounted partition of /dev/sdf"}`)
Expect(platform.UnmountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
})
It("unmount disk when the disk is not mounted", func() {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = false
mountDisk := buildUnmountDiskAction(platform)
result, err := mountDisk.Run("vol-123")
Expect(err).ToNot(HaveOccurred())
boshassert.MatchesJSONString(GinkgoT(), result, `{"message":"Partition of /dev/sdf is not mounted"}`)
Expect(platform.UnmountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
})
It("unmount disk when device path not found", func() {
platform := fakeplatform.NewFakePlatform()
mountDisk := buildUnmountDiskAction(platform)
_, err := mountDisk.Run("vol-456")
Expect(err).To(HaveOccurred())
})
})
}
示例3: buildPrepareAction
func buildPrepareAction() (action PrepareNetworkChangeAction, fs boshsys.FileSystem) {
platform := fakeplatform.NewFakePlatform()
fs = platform.GetFs()
action = NewPrepareNetworkChange(platform)
return
}
示例4: buildMigrateDiskAction
func buildMigrateDiskAction() (platform *fakeplatform.FakePlatform, action migrateDiskAction) {
platform = fakeplatform.NewFakePlatform()
settings := &fakesettings.FakeSettingsService{}
dirProvider := boshdirs.NewDirectoriesProvider("/foo")
action = newMigrateDisk(settings, platform, dirProvider)
return
}
示例5: init
func init() {
Describe("ReleaseApplySpec", func() {
var (
platform *fakeplatform.FakePlatform
action ReleaseApplySpecAction
)
BeforeEach(func() {
platform = fakeplatform.NewFakePlatform()
action = NewReleaseApplySpec(platform)
})
It("is synchronous", func() {
Expect(action.IsAsynchronous()).To(BeFalse())
})
It("is not persistent", func() {
Expect(action.IsPersistent()).To(BeFalse())
})
It("run", func() {
err := platform.GetFs().WriteFileString("/var/vcap/micro/apply_spec.json", `{"json":["objects"]}`)
Expect(err).ToNot(HaveOccurred())
value, err := action.Run()
Expect(err).ToNot(HaveOccurred())
Expect(value).To(Equal(map[string]interface{}{"json": []interface{}{"objects"}}))
})
})
}
示例6: buildApplyAction
func buildApplyAction() (*fakeappl.FakeApplier, *fakesys.FakeFileSystem, *fakeplatform.FakePlatform, applyAction) {
applier := fakeappl.NewFakeApplier()
platform := fakeplatform.NewFakePlatform()
fs := platform.Fs
action := newApply(applier, fs, platform)
return applier, fs, platform, action
}
示例7: TestHandlerProviderGetReturnsConcreteProvider
func TestHandlerProviderGetReturnsConcreteProvider(t *testing.T) {
platform := fakeplatform.NewFakePlatform()
blobstore := fakeblob.NewFakeBlobstore()
jobSupervisor := fakejobsuper.NewFakeJobSupervisor()
expectedPackageApplier := pa.NewConcretePackageApplier(
bc.NewFileBundleCollection("/fake-base-dir/data", "/fake-base-dir", "packages", platform.GetFs()),
blobstore,
platform.GetCompressor(),
)
expectedJobApplier := ja.NewRenderedJobApplier(
bc.NewFileBundleCollection("/fake-base-dir/data", "/fake-base-dir", "jobs", platform.GetFs()),
blobstore,
platform.GetCompressor(),
jobSupervisor,
)
dirProvider := boshdirs.NewDirectoriesProvider("/fake-base-dir")
expectedApplier := NewConcreteApplier(
expectedJobApplier,
expectedPackageApplier,
platform,
jobSupervisor,
dirProvider,
)
provider := NewApplierProvider(platform, blobstore, jobSupervisor, dirProvider)
applier := provider.Get()
assert.Equal(t, expectedApplier, applier)
}
示例8: TestAwsGetSettingsWhenDnsServersAreProvided
func TestAwsGetSettingsWhenDnsServersAreProvided(t *testing.T) {
fakeDnsResolver := &FakeDnsResolver{
LookupHostIp: "127.0.0.1",
}
registryTs, registryTsPort, expectedSettings := spinUpAwsRegistry(t)
defer registryTs.Close()
expectedUserData := fmt.Sprintf(`
{
"registry":{
"endpoint":"http://the.registry.name:%s"
},
"dns":{
"nameserver": ["8.8.8.8", "9.9.9.9"]
}
}`,
registryTsPort)
metadataTs := spinUpAwsMetadataServer(t, expectedUserData)
defer metadataTs.Close()
platform := fakeplatform.NewFakePlatform()
aws := NewAwsInfrastructure(metadataTs.URL, fakeDnsResolver, platform)
settings, err := aws.GetSettings()
assert.NoError(t, err)
assert.Equal(t, settings, expectedSettings)
assert.Equal(t, fakeDnsResolver.LookupHostHost, "the.registry.name")
assert.Equal(t, fakeDnsResolver.LookupHostDnsServers, []string{"8.8.8.8", "9.9.9.9"})
}
示例9: getFakeFactoryDependencies
func getFakeFactoryDependencies() (settings boshsettings.Settings, fs *fakesys.FakeFileSystem, platform *fakeplatform.FakePlatform, taskService *faketask.FakeService) {
settings = boshsettings.Settings{}
fs = &fakesys.FakeFileSystem{}
platform = fakeplatform.NewFakePlatform()
taskService = &faketask.FakeService{}
return
}
示例10: buildFactory
func buildFactory() (
deps concreteFactoryDependencies,
factory Factory) {
deps.settings = &fakesettings.FakeSettingsService{}
deps.platform = fakeplatform.NewFakePlatform()
deps.blobstore = &fakeblobstore.FakeBlobstore{}
deps.taskService = &faketask.FakeService{}
deps.notifier = fakenotif.NewFakeNotifier()
deps.applier = fakeappl.NewFakeApplier()
deps.compiler = fakecomp.NewFakeCompiler()
deps.jobSupervisor = fakejobsuper.NewFakeJobSupervisor()
deps.specService = fakeas.NewFakeV1Service()
deps.drainScriptProvider = boshdrain.NewConcreteDrainScriptProvider(nil, nil, deps.platform.GetDirProvider())
factory = NewFactory(
deps.settings,
deps.platform,
deps.blobstore,
deps.taskService,
deps.notifier,
deps.applier,
deps.compiler,
deps.jobSupervisor,
deps.specService,
deps.drainScriptProvider,
)
return
}
示例11: buildFactory
func buildFactory() (
deps concreteFactoryDependencies,
factory Factory) {
deps.settings = &fakesettings.FakeSettingsService{}
deps.platform = fakeplatform.NewFakePlatform()
deps.blobstore = &fakeblobstore.FakeBlobstore{}
deps.taskService = &faketask.FakeService{}
deps.notifier = fakenotif.NewFakeNotifier()
deps.applier = fakeappl.NewFakeApplier()
deps.compiler = fakecomp.NewFakeCompiler()
deps.monitor = fakemon.NewFakeMonitor()
deps.specService = fakeas.NewFakeV1Service()
deps.dirProvider = boshdirs.NewDirectoriesProvider("/foo")
deps.drainScriptProvider = boshdrain.NewDrainScriptProvider(nil, nil, deps.dirProvider)
factory = NewFactory(
deps.settings,
deps.platform,
deps.blobstore,
deps.taskService,
deps.notifier,
deps.applier,
deps.compiler,
deps.monitor,
deps.specService,
deps.dirProvider,
deps.drainScriptProvider,
)
return
}
示例12: TestUnmountDiskWhenDevicePathNotFound
func TestUnmountDiskWhenDevicePathNotFound(t *testing.T) {
platform := fakeplatform.NewFakePlatform()
mountDisk := buildUnmountDiskAction(platform)
_, err := mountDisk.Run("vol-456")
assert.Error(t, err)
}
示例13: getBootstrapDependencies
func getBootstrapDependencies() (inf *fakeinf.FakeInfrastructure, platform *fakeplatform.FakePlatform, dirProvider boshdir.DirectoriesProvider) {
inf = &fakeinf.FakeInfrastructure{}
inf.GetEphemeralDiskPathFound = true
inf.GetEphemeralDiskPathRealPath = "/dev/sdz"
platform = fakeplatform.NewFakePlatform()
dirProvider = boshdir.NewDirectoriesProvider("/var/vcap")
return
}
示例14: init
func init() {
Describe("dummyInfrastructure", func() {
It("get settings", func() {
fs := fakefs.NewFakeFileSystem()
dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")
platform := fakeplatform.NewFakePlatform()
fakeDevicePathResolver := fakedpresolv.NewFakeDevicePathResolver(1*time.Millisecond, platform.GetFs())
settingsPath := filepath.Join(dirProvider.BoshDir(), "dummy-cpi-agent-env.json")
expectedSettings := boshsettings.Settings{
AgentID: "123-456-789",
Blobstore: boshsettings.Blobstore{
Type: boshsettings.BlobstoreTypeDummy,
},
Mbus: "nats://127.0.0.1:4222",
}
existingSettingsBytes, _ := json.Marshal(expectedSettings)
fs.WriteFile(settingsPath, existingSettingsBytes)
dummy := NewDummyInfrastructure(fs, dirProvider, platform, fakeDevicePathResolver)
settings, err := dummy.GetSettings()
Expect(err).ToNot(HaveOccurred())
assert.Equal(GinkgoT(), settings, boshsettings.Settings{
AgentID: "123-456-789",
Blobstore: boshsettings.Blobstore{Type: boshsettings.BlobstoreTypeDummy},
Mbus: "nats://127.0.0.1:4222",
})
})
It("get settings errs when settings file does not exist", func() {
fs := fakefs.NewFakeFileSystem()
dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")
platform := fakeplatform.NewFakePlatform()
fakeDevicePathResolver := fakedpresolv.NewFakeDevicePathResolver(1*time.Millisecond, platform.GetFs())
dummy := NewDummyInfrastructure(fs, dirProvider, platform, fakeDevicePathResolver)
_, err := dummy.GetSettings()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Read settings file"))
})
})
}
示例15: TestUnmountDiskWhenDevicePathNotFound
func TestUnmountDiskWhenDevicePathNotFound(t *testing.T) {
platform := fakeplatform.NewFakePlatform()
mountDisk := buildUnmountDiskAction(platform)
payload := `{"arguments":["vol-456"]}`
_, err := mountDisk.Run([]byte(payload))
assert.Error(t, err)
}