var stdoutBuffer *bytes.Buffer

	BeforeEach(func() {
		stderrBuffer = new(bytes.Buffer)
		stdoutBuffer = new(bytes.Buffer)
		errorToReturn = nil
		startMessage, successMessage, failureMessage = "", "", ""
		cancelled = false
		fakeStreamer = new(fake_log_streamer.FakeLogStreamer)

		fakeStreamer.StderrReturns(stderrBuffer)
		fakeStreamer.StdoutReturns(stdoutBuffer)

		subStep = &fakes.FakeStep{
			PerformStub: func() error {
				fakeStreamer.Stdout().Write([]byte("RUNNING\n"))
				return errorToReturn
			},
			CancelStub: func() {
				cancelled = true
			},
		}

		logger = lagertest.NewTestLogger("test")
	})

	JustBeforeEach(func() {
		step = steps.NewEmitProgress(subStep, startMessage, successMessage, failureMessage, fakeStreamer, logger)
	})

	Context("running", func() {
示例#2
0
				BeforeEach(func() {
					fakeUploader := new(fake_uploader.FakeUploader)
					fakeUploader.UploadReturns(1024, nil)
					uploader = fakeUploader
				})

				Context("when an artifact is specified", func() {
					BeforeEach(func() {
						uploadAction.Artifact = "artifact"
					})

					It("streams the upload filesize", func() {
						err := step.Perform()
						Expect(err).NotTo(HaveOccurred())

						stdout := fakeStreamer.Stdout().(*gbytes.Buffer)
						Expect(stdout.Contents()).To(ContainSubstring("Uploaded artifact (1K)"))
					})
				})

				Context("when an artifact is not specified", func() {
					It("does not stream the upload information", func() {
						err := step.Perform()
						Expect(err).NotTo(HaveOccurred())

						stdout := fakeStreamer.Stdout().(*gbytes.Buffer)
						Expect(stdout.Contents()).To(BeEmpty())
					})
				})

				It("does not stream an error", func() {