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


Golang fakes.NewFakeFileSystem函數代碼示例

本文整理匯總了Golang中bosh/system/fakes.NewFakeFileSystem函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewFakeFileSystem函數的具體用法?Golang NewFakeFileSystem怎麽用?Golang NewFakeFileSystem使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewFakeFileSystem函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: createBlobManager

func createBlobManager() (blobManager BlobManager, fs *fakesys.FakeFileSystem) {
	fs = fakesys.NewFakeFileSystem()
	dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")

	blobManager = NewBlobManager(fs, dirProvider)
	return
}
開發者ID:UhuruSoftware,項目名稱:bosh_old,代碼行數:7,代碼來源:blob_manager_test.go

示例2: TestConfigure

func TestConfigure(t *testing.T) {
	jobsBc, _, _, monitor, applier := buildJobApplier()
	job := buildJob()

	fs := fakesys.NewFakeFileSystem()
	fs.WriteToFile("/path/to/job/monit", "some conf")
	fs.GlobPaths = []string{"/path/to/job/subjob.monit"}

	jobsBc.GetDirPath = "/path/to/job"
	jobsBc.GetDirFs = fs

	err := applier.Configure(job, 0)
	assert.NoError(t, err)

	assert.Equal(t, "/path/to/job/*.monit", fs.GlobPattern)
	assert.Equal(t, 2, len(monitor.AddJobArgs))

	firstArgs := fakemon.AddJobArgs{
		Name:       job.Name,
		Index:      0,
		ConfigPath: "/path/to/job/monit",
	}

	secondArgs := fakemon.AddJobArgs{
		Name:       job.Name + "_subjob",
		Index:      0,
		ConfigPath: "/path/to/job/subjob.monit",
	}
	assert.Equal(t, firstArgs, monitor.AddJobArgs[0])
	assert.Equal(t, secondArgs, monitor.AddJobArgs[1])
}
開發者ID:viglesiasce,項目名稱:bosh,代碼行數:31,代碼來源:rendered_job_applier_test.go

示例3: TestApplyCopiesFromDecompressedTmpPathToInstallPath

func TestApplyCopiesFromDecompressedTmpPathToInstallPath(t *testing.T) {
	jobsBc, blobstore, compressor, _, applier := buildJobApplier()
	job := buildJob()
	job.Source.PathInArchive = "fake-path-in-archive"

	fs := fakesys.NewFakeFileSystem()
	fs.TempDirDir = "fake-tmp-dir"
	fs.MkdirAll("fake-tmp-dir", os.FileMode(0))

	jobsBc.InstallFs = fs
	jobsBc.InstallPath = "fake-install-dir"
	fs.MkdirAll("fake-install-dir", os.FileMode(0))

	blobstore.GetFileName = "/dev/null"

	compressor.DecompressFileToDirCallBack = func() {
		fs.MkdirAll("fake-tmp-dir/fake-path-in-archive", os.FileMode(0))
		fs.WriteToFile("fake-tmp-dir/fake-path-in-archive/file", "file-contents")
	}

	err := applier.Apply(job)
	assert.NoError(t, err)
	fileInArchiveStat := fs.GetFileTestStat("fake-install-dir/file")
	assert.NotNil(t, fileInArchiveStat)
	assert.Equal(t, "file-contents", fileInArchiveStat.Content)
}
開發者ID:viglesiasce,項目名稱:bosh,代碼行數:26,代碼來源:rendered_job_applier_test.go

示例4: buildCompiler

func buildCompiler() (
	deps compilerDeps,
	compiler Compiler,
) {
	deps.compressor = fakecmd.NewFakeCompressor()
	deps.blobstore = &fakeblobstore.FakeBlobstore{}
	deps.fs = fakesys.NewFakeFileSystem()
	deps.runner = fakesys.NewFakeCmdRunner()
	deps.packageApplier = fakepa.NewFakePackageApplier()
	fakeBundleCollection := fakebc.NewFakeBundleCollection()
	bundleDefinition := boshmodels.Package{
		Name:    "pkg_name",
		Version: "pkg_version",
	}
	deps.bundle = fakeBundleCollection.FakeGet(bundleDefinition)
	deps.bundle.InstallPath = "/fake-dir/data/packages/pkg_name/pkg_version"
	deps.bundle.EnablePath = "/fake-dir/packages/pkg_name"
	deps.packagesBc = fakeBundleCollection

	compiler = NewConcreteCompiler(
		deps.compressor,
		deps.blobstore,
		deps.fs,
		deps.runner,
		boshdirs.NewDirectoriesProvider("/fake-dir"),
		deps.packageApplier,
		deps.packagesBc,
	)
	return
}
開發者ID:nkuacac,項目名稱:bosh,代碼行數:30,代碼來源:concrete_compiler_test.go

示例5: getNewProvider

func getNewProvider() (provider provider) {
	dirProvider := boshsys.NewDirectoriesProvider("/var/vcap")
	fs := fakefs.NewFakeFileSystem()

	provider = NewProvider(boshlog.NewLogger(boshlog.LEVEL_NONE), fs, dirProvider)
	return
}
開發者ID:kangaroo,項目名稱:bosh,代碼行數:7,代碼來源:provider_test.go

示例6: 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"))
		})
	})
}
開發者ID:punalpatel,項目名稱:bosh,代碼行數:45,代碼來源:dummy_infrastructure_test.go

示例7: TestNewDrainScript

func TestNewDrainScript(t *testing.T) {
	runner := fakesys.NewFakeCmdRunner()
	fs := fakesys.NewFakeFileSystem()
	dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")

	scriptProvider := NewConcreteDrainScriptProvider(runner, fs, dirProvider)
	drainScript := scriptProvider.NewDrainScript("foo")

	assert.Equal(t, drainScript.Path(), "/var/vcap/jobs/foo/bin/drain")
}
開發者ID:UhuruSoftware,項目名稱:bosh_old,代碼行數:10,代碼來源:concrete_drain_script_provider_test.go

示例8: TestGetSettingsErrsWhenSettingsFileDoesNotExist

func TestGetSettingsErrsWhenSettingsFileDoesNotExist(t *testing.T) {
	fs := fakefs.NewFakeFileSystem()
	dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")

	dummy := newDummyInfrastructure(fs, dirProvider)

	_, err := dummy.GetSettings()
	assert.Error(t, err)
	assert.Contains(t, err.Error(), "Read settings file")
}
開發者ID:UhuruSoftware,項目名稱:bosh_old,代碼行數:10,代碼來源:dummy_infrastructure_test.go

示例9: buildService

func buildService(NTPData string) (service Service) {
	fs := fakefs.NewFakeFileSystem()
	dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")

	if NTPData != "" {
		fs.WriteToFile("/var/vcap/bosh/log/ntpdate.out", NTPData)
	}

	service = NewConcreteService(fs, dirProvider)
	return
}
開發者ID:nkuacac,項目名稱:bosh,代碼行數:11,代碼來源:service_test.go

示例10: TestApplyErrsWhenJobDecompressErrs

func TestApplyErrsWhenJobDecompressErrs(t *testing.T) {
	jobsBc, _, compressor, applier := buildJobApplier()
	pkg := buildJob()

	compressor.DecompressFileToDirError = errors.New("fake-decompress-error")

	fs := fakesys.NewFakeFileSystem()
	jobsBc.InstallFs = fs

	err := applier.Apply(pkg)
	assert.Error(t, err)
	assert.Contains(t, err.Error(), "fake-decompress-error")
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:13,代碼來源:rendered_job_applier_test.go

示例11: init

func init() {
	Describe("Testing with Ginkgo", func() {
		It("get settings", func() {

			fs := fakefs.NewFakeFileSystem()
			dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")
			platform := fakeplatform.NewFakePlatform()

			settingsPath := filepath.Join(dirProvider.BaseDir(), "bosh", "settings.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.WriteToFile(settingsPath, string(existingSettingsBytes))

			dummy := NewDummyInfrastructure(fs, dirProvider, platform)

			settings, err := dummy.GetSettings()
			assert.NoError(GinkgoT(), err)

			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()

			dummy := NewDummyInfrastructure(fs, dirProvider, platform)

			_, err := dummy.GetSettings()
			assert.Error(GinkgoT(), err)
			assert.Contains(GinkgoT(), err.Error(), "Read settings file")
		})
	})
}
開發者ID:nkuacac,項目名稱:bosh,代碼行數:39,代碼來源:dummy_infrastructure_test.go

示例12: TestApplyInstallsAndEnablesJob

func TestApplyInstallsAndEnablesJob(t *testing.T) {
	jobsBc, _, _, applier := buildJobApplier()
	pkg := buildJob()

	fs := fakesys.NewFakeFileSystem()
	jobsBc.InstallFs = fs
	jobsBc.InstallPath = "fake-install-dir"
	fs.MkdirAll("fake-install-dir", os.FileMode(0))

	err := applier.Apply(pkg)
	assert.NoError(t, err)
	assert.True(t, jobsBc.IsInstalled(pkg))
	assert.True(t, jobsBc.IsEnabled(pkg))
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:14,代碼來源:rendered_job_applier_test.go

示例13: TestApplyErrsWhenTempDirErrs

func TestApplyErrsWhenTempDirErrs(t *testing.T) {
	jobsBc, blobstore, _, _, applier := buildJobApplier()
	job := buildJob()

	fs := fakesys.NewFakeFileSystem()
	fs.TempDirError = errors.New("fake-filesystem-tempdir-error")
	jobsBc.InstallFs = fs

	blobstore.GetFileName = "/dev/null"

	err := applier.Apply(job)
	assert.Error(t, err)
	assert.Contains(t, err.Error(), "fake-filesystem-tempdir-error")
}
開發者ID:viglesiasce,項目名稱:bosh,代碼行數:14,代碼來源:rendered_job_applier_test.go

示例14: TestApplyInstallsAndEnablesJob

func TestApplyInstallsAndEnablesJob(t *testing.T) {
	jobsBc, _, _, _, applier := buildJobApplier()
	job, bundle := buildJob(jobsBc)

	fs := fakesys.NewFakeFileSystem()
	bundle.InstallFs = fs
	bundle.InstallPath = "fake-install-dir"
	fs.MkdirAll("fake-install-dir", os.FileMode(0))

	err := applier.Apply(job)
	assert.NoError(t, err)
	assert.True(t, bundle.Installed)
	assert.True(t, bundle.Enabled)
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:14,代碼來源:rendered_job_applier_test.go

示例15: NewFakePlatform

func NewFakePlatform() (platform *FakePlatform) {
	platform = new(FakePlatform)
	platform.Fs = fakesys.NewFakeFileSystem()
	platform.Runner = fakesys.NewFakeCmdRunner()
	platform.FakeCompressor = fakecmd.NewFakeCompressor()
	platform.FakeCopier = fakecmd.NewFakeCopier()
	platform.FakeVitalsService = fakevitals.NewFakeService()
	platform.DevicePathResolver = fakedpresolv.NewFakeDevicePathResolver()
	platform.AddUserToGroupsGroups = make(map[string][]string)
	platform.SetupSshPublicKeys = make(map[string]string)
	platform.UserPasswords = make(map[string]string)
	platform.ScsiDiskMap = make(map[string]string)
	return
}
開發者ID:Jane4PKU,項目名稱:bosh,代碼行數:14,代碼來源:fake_platform.go


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