github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/shared/isolated/suggest_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"os/exec"
     5  
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  	. "github.com/onsi/gomega/gbytes"
     9  	. "github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("Suggest Command", func() {
    13  	When("a command is provided that is almost a command", func() {
    14  		It("gives suggestions", func() {
    15  			command := exec.Command("cf", "logn")
    16  			session, err := Start(command, GinkgoWriter, GinkgoWriter)
    17  			Eventually(session).Should(Exit(1))
    18  			Expect(err).NotTo(HaveOccurred())
    19  
    20  			Expect(session).To(Say("'logn' is not a registered command. See 'cf help -a'"))
    21  			Expect(session).To(Say("Did you mean?"))
    22  
    23  			Expect(session.Out.Contents()).To(ContainSubstring("login"))
    24  			Expect(session.Out.Contents()).To(ContainSubstring("logs"))
    25  		})
    26  	})
    27  
    28  	When("a command is provided that is not even close", func() {
    29  		It("gives suggestions", func() {
    30  			command := exec.Command("cf", "zzz")
    31  			session, err := Start(command, GinkgoWriter, GinkgoWriter)
    32  
    33  			Eventually(session).Should(Exit(1))
    34  
    35  			Expect(err).NotTo(HaveOccurred())
    36  			Expect(session).To(Say("'zzz' is not a registered command. See 'cf help -a'"))
    37  			Expect(session).ToNot(Say("Did you mean?"))
    38  		})
    39  	})
    40  })