Example #1
0
			err := cmd.Execute(flagContext)
			Expect(err).NotTo(HaveOccurred())

			Eventually(buffer.Contents).Should(ContainSubstring("A command line tool to interact with Cloud Foundry"))
			Eventually(buffer).Should(gbytes.Say("CF_TRACE=true"))
		})
	})

	Context("when a command name is provided as an argument", func() {
		Context("When the command exists", func() {
			It("prints the usage help for the command", func() {
				flagContext.Parse("target")
				err := cmd.Execute(flagContext)
				Expect(err).NotTo(HaveOccurred())

				Expect(fakeUI.SayCallCount()).To(Equal(1))
				output, _ := fakeUI.SayArgsForCall(0)
				Expect(output).To(ContainSubstring("target - Set or view the targeted org or space"))
			})

			Context("i18n translations", func() {
				var originalT func(string, ...interface{}) string

				BeforeEach(func() {
					originalT = i18n.T
				})

				AfterEach(func() {
					i18n.T = originalT
				})
Example #2
0
		b = make([]byte, 1024)
		progressReader = NewProgressReader(testFile, ui, 1*time.Millisecond)
		progressReader.SetTotalSize(fileStat.Size())
	})

	It("prints progress while content is being read", func() {
		for {
			time.Sleep(50 * time.Microsecond)
			_, err := progressReader.Read(b)
			if err != nil {
				break
			}
		}

		Expect(ui.SayCallCount()).To(Equal(1))
		Expect(ui.SayArgsForCall(0)).To(ContainSubstring("\rDone "))

		Expect(ui.PrintCapturingNoOutputCallCount()).To(BeNumerically(">", 0))
		status, _ := ui.PrintCapturingNoOutputArgsForCall(0)
		Expect(status).To(ContainSubstring("uploaded..."))
		status, _ = ui.PrintCapturingNoOutputArgsForCall(ui.PrintCapturingNoOutputCallCount() - 1)
		Expect(status).To(Equal("\r                             "))
	})

	It("reads the correct number of bytes", func() {
		bytesRead := 0

		for {
			n, err := progressReader.Read(b)
			if err != nil {