cmdRunner.AddCmdResult("fake-cmd fake-args", fakesys.FakeCmdResult{
					Stdout:     "fake-long-output-stdout",
					Stderr:     "fake-long-output-stderr",
					ExitStatus: 1,
					Error:      errors.New("fake-packaging-error"),
				})

				result, err := runner.RunCommand("fake-log-dir-name", "fake-log-file-name", cmd)
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(Equal("Command exited with 1; Truncated stdout: g-output-stdout, Truncated stderr: g-output-stderr"))
				Expect(result).To(BeNil())
			})

			It("return an error if it fails to read from saved stdout file", func() {
				filePath := "/fake-base-dir/fake-log-dir-name/fake-log-file-name.stdout.log"
				file := fakesys.NewFakeFile(filePath, fs)
				file.ReadAtErr = errors.New("fake-read-at-err")

				fs.RegisterOpenFile(filePath, file)

				result, err := runner.RunCommand("fake-log-dir-name", "fake-log-file-name", cmd)
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-read-at-err"))
				Expect(result).To(BeNil())
			})

			It("return an error if it fails to read from saved stderr file", func() {
				filePath := "/fake-base-dir/fake-log-dir-name/fake-log-file-name.stderr.log"
				file := fakesys.NewFakeFile(filePath, fs)
				file.ReadAtErr = errors.New("fake-read-at-err")
Exemple #2
0
				fs = fakesys.NewFakeFileSystem()
				runner = NewConcretePSRunner(fs, logger)
			})

			Context("when creating Tempfile fails", func() {
				It("errors out", func() {
					fs.TempFileError = errors.New("boo")

					_, _, err := runner.RunCommand(PSCommand{})
					Expect(err.Error()).To(Equal("Creating tempfile: boo"))
				})
			})

			Context("when writing to the Tempfile fails", func() {
				It("errors out", func() {
					tempfile := fakesys.NewFakeFile("path", fs)
					fs.ReturnTempFile = tempfile
					tempfile.WriteErr = errors.New("foo")

					_, _, err := runner.RunCommand(PSCommand{})
					Expect(err.Error()).To(Equal("Writing to tempfile: foo"))
				})
			})

			Context("when closing Tempfile fails", func() {
				It("errors out", func() {
					tempfile := fakesys.NewFakeFile("path", fs)
					fs.ReturnTempFile = tempfile
					tempfile.CloseErr = errors.New("oh noes")

					_, _, err := runner.RunCommand(PSCommand{})
	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},
Exemple #4
0
		fs                *fakesys.FakeFileSystem
		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"))