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


Golang FakeFileSystem.ReturnTempFile方法代碼示例

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


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

示例1:

			options := map[string]interface{}{}

			blobstore := NewExternalBlobstore("fake-provider", options, fs, runner, uuidGen, configPath)

			err := blobstore.Validate()
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("not found in PATH"))
		})
	})

	Describe("Get", func() {
		It("external get", func() {
			tempFile, err := fs.TempFile("bosh-blobstore-external-TestGet")
			Expect(err).ToNot(HaveOccurred())

			fs.ReturnTempFile = tempFile
			defer fs.RemoveAll(tempFile.Name())

			fileName, err := blobstore.Get("fake-blob-id", "")
			Expect(err).ToNot(HaveOccurred())

			Expect(len(runner.RunCommands)).To(Equal(1))
			Expect(runner.RunCommands[0]).To(Equal([]string{
				"bosh-blobstore-fake-provider", "-c", configPath, "get",
				"fake-blob-id",
				tempFile.Name(),
			}))

			Expect(fileName).To(Equal(tempFile.Name()))
			Expect(fs.FileExists(tempFile.Name())).To(BeTrue())
		})
開發者ID:jianqiu,項目名稱:bosh-agent,代碼行數:31,代碼來源:external_blobstore_test.go

示例2:

	var (
		cmdRunner *fakesys.FakeCmdRunner
		fs        *fakesys.FakeFileSystem
		deployer  Deployer
	)

	BeforeEach(func() {
		fs = fakesys.NewFakeFileSystem()
		cmdRunner = fakesys.NewFakeCmdRunner()
		directorInfo := bltaction.DirectorInfo{
			UUID: "fake-director-uuid",
			URL:  "fake-director-url",
		}
		boshCmd := boshsys.Command{Name: "bosh"}

		fs.ReturnTempFile = fakesys.NewFakeFile("cli-config-path", fs)

		cliRunner := bltclirunner.NewRunner(boshCmd, cmdRunner, fs)
		cliRunner.Configure()
		renderer := NewRenderer(fs)

		cmdRunner.AddCmdResult("bosh -n -c cli-config-path deploy", fakesys.FakeCmdResult{
			Stdout: "Task 15 done",
		})

		cmdRunner.AddCmdResult("bosh -n -c cli-config-path deploy", fakesys.FakeCmdResult{
			Stdout: "Task 20 done",
		})

		parameters := bftconfig.Parameters{
			NameLength:                 []int{5, 10},
開發者ID:cloudfoundry-incubator,項目名稱:bosh-fuzz-tests,代碼行數:31,代碼來源:deployer_test.go

示例3:

					Expect(err).ToNot(HaveOccurred())

					Expect(fakeStage.PerformCalls[0].Name).To(Equal("Downloading fake-description"))
					Expect(fakeStage.PerformCalls[0].SkipError.Error()).To(Equal("Found in local cache: Already downloaded"))
				})
			})

			Context("when tarball is not present in cache", func() {
				var (
					tempDownloadFilePath string
				)

				BeforeEach(func() {
					tempDownloadFile, err := ioutil.TempFile("", "temp-download-file")
					Expect(err).ToNot(HaveOccurred())
					fs.ReturnTempFile = tempDownloadFile
					tempDownloadFilePath = tempDownloadFile.Name()
					sha1Calculator.SetCalculateBehavior(map[string]fakebicrypto.CalculateInput{
						tempDownloadFilePath: {Sha1: "fake-sha1"},
					})
				})

				AfterEach(func() {
					os.RemoveAll(tempDownloadFilePath)
				})

				Context("when downloading succeds", func() {
					BeforeEach(func() {
						httpClient.SetGetBehavior("fake-body", 200, nil)
						httpClient.SetGetBehavior("fake-body", 200, nil)
						httpClient.SetGetBehavior("fake-body", 200, nil)
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:31,代碼來源:provider_test.go

示例4:

		blobstore         Blobstore
	)

	BeforeEach(func() {
		fakeDavClient = fakeboshdavcli.NewFakeClient()
		fakeUUIDGenerator = fakeuuid.NewFakeGenerator()
		fs = fakesys.NewFakeFileSystem()
		logger := boshlog.NewLogger(boshlog.LevelNone)

		blobstore = NewBlobstore(fakeDavClient, fakeUUIDGenerator, fs, logger)
	})

	Describe("Get", func() {
		BeforeEach(func() {
			fakeFile := fakesys.NewFakeFile("fake-destination-path", fs)
			fs.ReturnTempFile = fakeFile
		})

		It("gets the blob from the blobstore", func() {
			fakeDavClient.GetContents = ioutil.NopCloser(strings.NewReader("fake-content"))

			localBlob, err := blobstore.Get("fake-blob-id")
			Expect(err).ToNot(HaveOccurred())
			defer localBlob.DeleteSilently()

			Expect(fakeDavClient.GetPath).To(Equal("fake-blob-id"))
		})

		It("saves the blob to the destination path", func() {
			fakeDavClient.GetContents = ioutil.NopCloser(strings.NewReader("fake-content"))
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:30,代碼來源:blobstore_test.go


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