github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/global/running_environment_variable_group_command_test.go (about)

     1  package global
     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("running-environment-variable-group command", func() {
    12  	Describe("help", func() {
    13  		When("--help flag is set", func() {
    14  			It("displays command usage to output", func() {
    15  				session := helpers.CF("running-environment-variable-group", "--help")
    16  
    17  				Eventually(session).Should(Say("NAME:"))
    18  				Eventually(session).Should(Say("running-environment-variable-group - Retrieve the contents of the running environment variable group"))
    19  				Eventually(session).Should(Say("USAGE:"))
    20  				Eventually(session).Should(Say("cf running-environment-variable-group"))
    21  				Eventually(session).Should(Say("ALIAS:"))
    22  				Eventually(session).Should(Say("revg"))
    23  				Eventually(session).Should(Say("SEE ALSO:"))
    24  				Eventually(session).Should(Say("env, staging-environment-variable-group"))
    25  				Eventually(session).Should(Exit(0))
    26  			})
    27  		})
    28  	})
    29  
    30  	When("the environment is not setup correctly", func() {
    31  		It("fails with the appropriate errors", func() {
    32  			helpers.CheckEnvironmentTargetedCorrectly(false, false, "", "running-environment-variable-group")
    33  		})
    34  	})
    35  
    36  	When("the environment is set up correctly", func() {
    37  		var userName string
    38  
    39  		BeforeEach(func() {
    40  			helpers.LoginCF()
    41  			userName, _ = helpers.GetCredentials()
    42  		})
    43  
    44  		When("there are no variables in the group", func() {
    45  			It("displays an empty-list message", func() {
    46  				session := helpers.CF("running-environment-variable-group")
    47  
    48  				Eventually(session).Should(Say(`Getting the running environment variable group as %s\.\.\.`, userName))
    49  				Eventually(session).Should(Say(`No running environment variable group has been set\.`))
    50  				Eventually(session).Should(Exit(0))
    51  			})
    52  		})
    53  
    54  		When("there are variables in the group", func() {
    55  			BeforeEach(func() {
    56  				envVars := `{"key_one": "one"}`
    57  				session := helpers.CF("set-running-environment-variable-group", envVars)
    58  				Eventually(session).Should(Exit(0))
    59  			})
    60  
    61  			AfterEach(func() {
    62  				envVars := `{}`
    63  				session := helpers.CF("set-running-environment-variable-group", envVars)
    64  				Eventually(session).Should(Exit(0))
    65  			})
    66  
    67  			It("displays the environment variables in a table", func() {
    68  				session := helpers.CF("running-environment-variable-group")
    69  
    70  				Eventually(session).Should(Say(`Getting the running environment variable group as %s\.\.\.`, userName))
    71  				Eventually(session).Should(Say(`variable name\s+assigned value`))
    72  				Eventually(session).Should(Say(`key_one\s+one`))
    73  				Eventually(session).Should(Exit(0))
    74  			})
    75  		})
    76  	})
    77  })