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

     1  package experimental
     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("v3-apps command", func() {
    12  	var (
    13  		orgName   string
    14  		spaceName string
    15  		appName1  string
    16  		appName2  string
    17  	)
    18  
    19  	BeforeEach(func() {
    20  		orgName = helpers.NewOrgName()
    21  		spaceName = helpers.NewSpaceName()
    22  		appName1 = helpers.PrefixedRandomName("app1")
    23  		appName2 = helpers.PrefixedRandomName("app2")
    24  		helpers.TurnOffExperimental()
    25  	})
    26  
    27  	AfterEach(func() {
    28  		helpers.TurnOnExperimental()
    29  	})
    30  
    31  	Describe("help", func() {
    32  		When("--help flag is set", func() {
    33  			It("Displays command usage to output", func() {
    34  				session := helpers.CF("v3-apps", "--help")
    35  
    36  				Eventually(session).Should(Say("NAME:"))
    37  				Eventually(session).Should(Say("v3-apps - List all apps in the target space"))
    38  				Eventually(session).Should(Say("USAGE:"))
    39  				Eventually(session).Should(Say("cf v3-apps"))
    40  
    41  				Eventually(session).Should(Exit(0))
    42  			})
    43  		})
    44  	})
    45  
    46  	It("displays the experimental warning", func() {
    47  		session := helpers.CF("v3-apps")
    48  		Eventually(session.Err).Should(Say("This command is in EXPERIMENTAL stage and may change without notice"))
    49  		Eventually(session).Should(Exit())
    50  	})
    51  
    52  	When("the environment is not setup correctly", func() {
    53  		It("fails with the appropriate errors", func() {
    54  			helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "v3-apps")
    55  		})
    56  	})
    57  
    58  	When("the environment is set up correctly", func() {
    59  		var userName string
    60  
    61  		BeforeEach(func() {
    62  			helpers.SetupCF(orgName, spaceName)
    63  			userName, _ = helpers.GetCredentials()
    64  		})
    65  
    66  		AfterEach(func() {
    67  			helpers.QuickDeleteOrg(orgName)
    68  		})
    69  
    70  		Context("with no apps", func() {
    71  			It("displays empty list", func() {
    72  				session := helpers.CF("v3-apps")
    73  				Eventually(session).Should(Say(`Getting apps in org %s / space %s as %s\.\.\.`, orgName, spaceName, userName))
    74  				Eventually(session).Should(Say("No apps found"))
    75  				Eventually(session).Should(Exit(0))
    76  			})
    77  		})
    78  
    79  		Context("with existing apps", func() {
    80  			var domainName string
    81  
    82  			BeforeEach(func() {
    83  				helpers.WithProcfileApp(func(appDir string) {
    84  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-push", appName2)).Should(Exit(0))
    85  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-push", appName1)).Should(Exit(0))
    86  				})
    87  
    88  				domainName = helpers.DefaultSharedDomain()
    89  			})
    90  
    91  			It("displays apps in the list", func() {
    92  				session := helpers.CF("v3-apps")
    93  				Eventually(session).Should(Say(`Getting apps in org %s / space %s as %s\.\.\.`, orgName, spaceName, userName))
    94  				Eventually(session).Should(Say(`name\s+requested state\s+processes\s+routes`))
    95  				Eventually(session).Should(Say(`%s\s+started\s+web:1/1, console:0/0\s+%s\.%s`, appName1, appName1, domainName))
    96  				Eventually(session).Should(Say(`%s\s+started\s+web:1/1, console:0/0\s+%s\.%s`, appName2, appName2, domainName))
    97  
    98  				Eventually(session).Should(Exit(0))
    99  			})
   100  
   101  			When("one app is stopped", func() {
   102  				BeforeEach(func() {
   103  					Eventually(helpers.CF("stop", appName1)).Should(Exit(0))
   104  				})
   105  
   106  				It("displays app as stopped", func() {
   107  					session := helpers.CF("v3-apps")
   108  					Eventually(session).Should(Say(`Getting apps in org %s / space %s as %s\.\.\.`, orgName, spaceName, userName))
   109  					Eventually(session).Should(Say(`name\s+requested state\s+processes\s+routes`))
   110  					Eventually(session).Should(Say(`%s\s+stopped\s+web:0/1, console:0/0\s+%s\.%s`, appName1, appName1, domainName))
   111  					Eventually(session).Should(Say(`%s\s+started\s+web:1/1, console:0/0\s+%s\.%s`, appName2, appName2, domainName))
   112  
   113  					Eventually(session).Should(Exit(0))
   114  				})
   115  			})
   116  		})
   117  	})
   118  })