github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/fly/integration/help_test.go (about)

     1  package integration_test
     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("Fly CLI", func() {
    13  	Describe("help", func() {
    14  		It("prints help", func() {
    15  			flyCmd := exec.Command(flyPath, "help")
    16  
    17  			sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
    18  			Expect(err).NotTo(HaveOccurred())
    19  
    20  			<-sess.Exited
    21  			Expect(sess.ExitCode()).To(Equal(0))
    22  
    23  			Expect(sess.Out).To(gbytes.Say("Usage:"))
    24  			Expect(sess.Out).To(gbytes.Say("Application Options:"))
    25  			Expect(sess.Out).To(gbytes.Say("Help Options:"))
    26  			Expect(sess.Out).To(gbytes.Say("Available commands:"))
    27  		})
    28  	})
    29  
    30  	Context("when invoking binary without flags", func() {
    31  		It("prints help", func() {
    32  			flyCmd := exec.Command(flyPath)
    33  
    34  			sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
    35  			Expect(err).NotTo(HaveOccurred())
    36  
    37  			<-sess.Exited
    38  			Expect(sess.ExitCode()).To(Equal(0))
    39  
    40  			Expect(sess.Out).To(gbytes.Say("Usage:"))
    41  			Expect(sess.Out).To(gbytes.Say("Application Options:"))
    42  			Expect(sess.Out).To(gbytes.Say("Help Options:"))
    43  			Expect(sess.Out).To(gbytes.Say("Available commands:"))
    44  		})
    45  	})
    46  
    47  	Context("when invoking a subcommand with -h flag", func() {
    48  		It("prints help for the given subcommand", func() {
    49  			flyCmd := exec.Command(flyPath, "completion", "-h")
    50  
    51  			sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
    52  			Expect(err).NotTo(HaveOccurred())
    53  
    54  			<-sess.Exited
    55  			Expect(sess.ExitCode()).To(Equal(0))
    56  			Expect(sess.Out).To(gbytes.Say("completion command options"))
    57  		})
    58  	})
    59  })