github.com/loafoe/cli@v7.1.0+incompatible/integration/v6/push/target_check_test.go (about)

     1  package push
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  	. "github.com/onsi/gomega/gbytes"
     8  	. "github.com/onsi/gomega/gexec"
     9  )
    10  
    11  var _ = Describe("push targetting", func() {
    12  	AfterEach(func() {
    13  		helpers.SetAPI()
    14  		helpers.LoginCF()
    15  		helpers.TargetOrg(organization)
    16  	})
    17  
    18  	When("the environment is not setup correctly", func() {
    19  		When("no API endpoint is set", func() {
    20  			BeforeEach(func() {
    21  				helpers.UnsetAPI()
    22  			})
    23  
    24  			It("fails with no API endpoint set message", func() {
    25  				session := helpers.CF(PushCommandName, "wut")
    26  				Eventually(session).Should(Say("FAILED"))
    27  				Eventually(session.Err).Should(Say("No API endpoint set. Use 'cf login' or 'cf api' to target an endpoint."))
    28  				Eventually(session).Should(Exit(1))
    29  			})
    30  		})
    31  
    32  		When("not logged in", func() {
    33  			BeforeEach(func() {
    34  				helpers.LogoutCF()
    35  			})
    36  
    37  			It("fails with not logged in message", func() {
    38  				session := helpers.CF(PushCommandName, "wut")
    39  				Eventually(session).Should(Say("FAILED"))
    40  				Eventually(session.Err).Should(Say("Not logged in. Use 'cf login' or 'cf login --sso' to log in."))
    41  				Eventually(session).Should(Exit(1))
    42  			})
    43  		})
    44  
    45  		When("there is no org set", func() {
    46  			BeforeEach(func() {
    47  				helpers.LogoutCF()
    48  				helpers.LoginCF()
    49  			})
    50  
    51  			It("fails with no targeted org error message", func() {
    52  				session := helpers.CF(PushCommandName, "wut")
    53  				Eventually(session).Should(Say("FAILED"))
    54  				Eventually(session.Err).Should(Say("No org targeted, use 'cf target -o ORG' to target an org."))
    55  				Eventually(session).Should(Exit(1))
    56  			})
    57  		})
    58  
    59  		When("there is no space set", func() {
    60  			BeforeEach(func() {
    61  				helpers.LogoutCF()
    62  				helpers.LoginCF()
    63  				helpers.TargetOrg(organization)
    64  			})
    65  
    66  			It("fails with no targeted space error message", func() {
    67  				session := helpers.CF(PushCommandName, "wut")
    68  				Eventually(session).Should(Say("FAILED"))
    69  				Eventually(session.Err).Should(Say("No space targeted, use 'cf target -s SPACE' to target a space."))
    70  				Eventually(session).Should(Exit(1))
    71  			})
    72  		})
    73  	})
    74  })