github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/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 18 Eventually(session).Should(Exit(1)) 19 Expect(err).NotTo(HaveOccurred()) 20 21 Expect(session.Err).To(Say("'logn' is not a registered command. See 'cf help -a'")) 22 Expect(session.Err).To(Say("Did you mean?")) 23 24 Expect(session.Err.Contents()).To(ContainSubstring("login")) 25 Expect(session.Err.Contents()).To(ContainSubstring("logs")) 26 }) 27 }) 28 29 When("a command is provided that is not even close", func() { 30 It("gives suggestions", func() { 31 command := exec.Command("cf", "zzz") 32 session, err := Start(command, GinkgoWriter, GinkgoWriter) 33 34 Eventually(session).Should(Exit(1)) 35 Expect(err).NotTo(HaveOccurred()) 36 37 Expect(session.Err).To(Say("'zzz' is not a registered command. See 'cf help -a'")) 38 Expect(session.Err).ToNot(Say("Did you mean?")) 39 }) 40 }) 41 })