示例#1
0
import (
	"os/exec"

	helpers "code.cloudfoundry.org/cli/integration/helpers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gbytes"
	. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Config", func() {
	Describe("Enable Color", func() {
		Context("when color is enabled", func() {
			It("prints colors", func() {
				command := exec.Command("cf", "help")
				command.Env = helpers.AddOrReplaceEnvironment("CF_COLOR", "true")
				session, err := Start(command, GinkgoWriter, GinkgoWriter)
				Expect(err).NotTo(HaveOccurred())
				Eventually(session).Should(Say("\x1b\\[38;1m"))
			})
		})

		Context("when color is disabled", func() {
			It("does not print colors", func() {
				command := exec.Command("cf", "help")
				command.Env = helpers.AddOrReplaceEnvironment("CF_COLOR", "false")
				session, err := Start(command, GinkgoWriter, GinkgoWriter)
				Expect(err).NotTo(HaveOccurred())

				Eventually(session).Should(Exit(0))
				Expect(session).NotTo(Say("\x1b\\[38;1m"))
	DescribeTable("outputs help in different languages",
		func(setup func() *exec.Cmd) {
			Skip("Pending discussion on internationalization support")
			cmd := setup()
			session, err := Start(cmd, GinkgoWriter, GinkgoWriter)
			Expect(err).NotTo(HaveOccurred())

			Eventually(session).Should(Say("push - Envoyer"))
			Eventually(session).Should(Say("SYNTAXE :"))
			Eventually(session).Should(Say("Envoyez par commande push"))
			Eventually(session).Should(Say("-i\\s+Nombre d'instances"))
			Eventually(session).Should(Exit(0))
		},

		Entry("when the locale is set in the config", func() *exec.Cmd {
			cmd := exec.Command("cf", "config", "--locale", "fr-FR")
			session, err := Start(cmd, GinkgoWriter, GinkgoWriter)
			Expect(err).NotTo(HaveOccurred())
			Eventually(session).Should(Exit(0))

			return exec.Command("cf", "push", "--help")
		}),

		Entry("when the the LANG environment variable is set", func() *exec.Cmd {
			cmd := exec.Command("cf", "push", "--help")
			cmd.Env = helpers.AddOrReplaceEnvironment("LANG", "fr-FR")
			return cmd
		}),
	)
})
示例#3
0
var _ = Describe("Verbose", func() {
	DescribeTable("displays verbose output",
		func(command func() *exec.Cmd) {
			login := exec.Command("cf", "auth", "admin", "admin")
			loginSession, err := Start(login, GinkgoWriter, GinkgoWriter)
			Expect(err).NotTo(HaveOccurred())
			Eventually(loginSession).Should(Exit(0))

			cmd := command()
			session, err := Start(cmd, GinkgoWriter, GinkgoWriter)
			Expect(err).NotTo(HaveOccurred())

			Eventually(session).Should(Say("REQUEST:"))
			Eventually(session).Should(Say("GET /v2/organizations"))
			Eventually(session).Should(Say("RESPONSE:"))
			Eventually(session).Should(Exit(0))
		},

		Entry("when the -v option is provided with additional command", func() *exec.Cmd {
			return exec.Command("cf", "-v", "orgs")
		}),

		Entry("when the CF_TRACE env variable is set", func() *exec.Cmd {
			cmd := exec.Command("cf", "orgs")
			cmd.Env = helpers.AddOrReplaceEnvironment("CF_TRACE", "true")
			return cmd
		}),
	)
})