github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/v6/isolated/set_env_command_test.go (about)

     1  package isolated
     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("set-env command", func() {
    12  	When("the --help flag provided", func() {
    13  		It("displays the usage text", func() {
    14  			session := helpers.CF("set-env", "--help")
    15  			Eventually(session).Should(Say("NAME:"))
    16  			Eventually(session).Should(Say("set-env - Set an env variable for an app"))
    17  			Eventually(session).Should(Say("USAGE:"))
    18  			Eventually(session).Should(Say("cf set-env APP_NAME ENV_VAR_NAME ENV_VAR_VALUE"))
    19  			Eventually(session).Should(Say("ALIAS:"))
    20  			Eventually(session).Should(Say("se"))
    21  			Eventually(session).Should(Say("SEE ALSO:"))
    22  			Eventually(session).Should(Say("apps, env, restart, set-running-environment-variable-group, set-staging-environment-variable-group, unset-env"))
    23  			Eventually(session).Should(Exit(0))
    24  		})
    25  	})
    26  	When("the a name and value are provided", func() {
    27  		var (
    28  			orgName   string
    29  			spaceName string
    30  			appName   string
    31  		)
    32  
    33  		BeforeEach(func() {
    34  			orgName = helpers.NewOrgName()
    35  			spaceName = helpers.NewSpaceName()
    36  			appName = helpers.NewAppName()
    37  			helpers.SetupCF(orgName, spaceName)
    38  			helpers.WithEmptyFilesApp(func(appDir string) {
    39  				Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0))
    40  			})
    41  		})
    42  
    43  		It("sets the environment value but doesn't output the value", func() {
    44  			session := helpers.CF("set-env", appName, "key", "value")
    45  			Eventually(session).Should(Exit(0))
    46  			Expect(session).Should(Say("Setting env variable 'key' for app %s in org %s / space %s ", appName, orgName, spaceName))
    47  			Expect(session).Should(Say("OK"))
    48  			session = helpers.CF("restart", appName)
    49  			Eventually(session).Should(Exit(0))
    50  			session = helpers.CF("env", appName)
    51  			Eventually(session).Should(Exit(0))
    52  			Expect(session).Should(Say(`key: value`))
    53  		})
    54  	})
    55  })