github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v6/global/buildpacks_command_test.go (about)

     1  package global
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
     7  	"code.cloudfoundry.org/cli/integration/helpers"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  	. "github.com/onsi/gomega/gexec"
    12  )
    13  
    14  var _ = Describe("buildpacks command", func() {
    15  
    16  	When("--help is passed", func() {
    17  		It("displays the help message", func() {
    18  			session := helpers.CF("buildpacks", "--help")
    19  			Eventually(session).Should(Say("NAME:"))
    20  			Eventually(session).Should(Say("buildpacks - List all buildpacks"))
    21  			Eventually(session).Should(Say("USAGE:"))
    22  			Eventually(session).Should(Say("cf buildpacks"))
    23  			Eventually(session).Should(Say("SEE ALSO:"))
    24  			Eventually(session).Should(Say("push"))
    25  			Eventually(session).Should(Exit(0))
    26  		})
    27  	})
    28  
    29  	When("environment is not set up", func() {
    30  		It("displays an error and exits 1", func() {
    31  			Skip("Unrefactored command is writing login errors to STDOUT; remove skip when refactored")
    32  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "buildpacks")
    33  		})
    34  
    35  		It("displays an error and exits 1", func() {
    36  			helpers.UnrefactoredCheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "buildpacks")
    37  		})
    38  	})
    39  
    40  	When("too many args are passed", func() {
    41  		It("displays FAILED, then usage, then exits 1", func() {
    42  			session := helpers.CF("buildpacks", "no-further-args-allowed")
    43  			Eventually(session).Should(Say("FAILED"))
    44  			Eventually(session).Should(Say("NAME:"))
    45  			Eventually(session).Should(Say("buildpacks - List all buildpacks"))
    46  			Eventually(session).Should(Say("USAGE:"))
    47  			Eventually(session).Should(Say("cf buildpacks"))
    48  			Eventually(session).Should(Exit(1))
    49  		})
    50  	})
    51  
    52  	When("the targeted API supports stack association", func() {
    53  		BeforeEach(func() {
    54  			helpers.SkipIfVersionLessThan(ccversion.MinVersionBuildpackStackAssociationV2)
    55  		})
    56  
    57  		It("lists the buildpacks with the stack column", func() {
    58  			helpers.LoginCF()
    59  			session := helpers.CF("buildpacks")
    60  			Eventually(session).Should(Say("Getting buildpacks..."))
    61  			Eventually(session).Should(Say(`buildpack\s+position\s+enabled\s+locked\s+filename\s+stack`))
    62  
    63  			buildpackNameRegex := `staticfile_buildpack`
    64  			positionRegex := `\d+`
    65  			boolRegex := `(true|false)`
    66  			buildpackFileRegex := `staticfile[-_]buildpack-\S+`
    67  			stackRegex := `(cflinuxfs[23]|windows.+)`
    68  
    69  			Eventually(session).Should(Say(fmt.Sprintf(`%s\s+%s\s+%s\s+%s\s+%s\s+%s`, buildpackNameRegex,
    70  				positionRegex, boolRegex, boolRegex, buildpackFileRegex, stackRegex)))
    71  			Eventually(session).Should(Exit(0))
    72  		})
    73  	})
    74  
    75  	When("the targeted API does not support stack association", func() {
    76  		BeforeEach(func() {
    77  			helpers.SkipIfVersionAtLeast(ccversion.MinVersionBuildpackStackAssociationV2)
    78  		})
    79  
    80  		It("includes the stack column but does not include the stack values", func() {
    81  			helpers.LoginCF()
    82  			session := helpers.CF("buildpacks")
    83  			Eventually(session).Should(Say("Getting buildpacks..."))
    84  			Eventually(session).Should(Say(`buildpack\s+position\s+enabled\s+locked\s+filename\s+stack\n`))
    85  
    86  			buildpackNameRegex := `staticfile_buildpack`
    87  			positionRegex := `\d+`
    88  			boolRegex := `(true|false)`
    89  			buildpackFileRegex := `staticfile[-_]buildpack-\S+`
    90  
    91  			Eventually(session).Should(Say(fmt.Sprintf(`%s\s+%s\s+%s\s+%s\s+%s\n`, buildpackNameRegex,
    92  				positionRegex, boolRegex, boolRegex, buildpackFileRegex)))
    93  			Eventually(session).Should(Exit(0))
    94  		})
    95  	})
    96  })