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

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"code.cloudfoundry.org/cli/integration/helpers"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/ginkgo/extensions/table"
    10  	. "github.com/onsi/gomega"
    11  	. "github.com/onsi/gomega/gbytes"
    12  	. "github.com/onsi/gomega/gexec"
    13  )
    14  
    15  var _ = Describe("push with different start command values", func() {
    16  	var (
    17  		appName string
    18  	)
    19  
    20  	BeforeEach(func() {
    21  		appName = helpers.NewAppName()
    22  	})
    23  
    24  	It("sets the start command correctly for the pushed app", func() {
    25  		helpers.WithHelloWorldApp(func(dir string) {
    26  			initialPush := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName)
    27  			Eventually(initialPush).Should(Exit(0))
    28  
    29  			session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    30  				PushCommandName, appName,
    31  				"--start-command", fmt.Sprintf("%s && echo hello", helpers.ModernStaticfileBuildpackStartCommand))
    32  			Eventually(session).Should(Say(`type:\s+web`))
    33  			Eventually(session).Should(Say(`start command:\s+%s && echo hello`, helpers.ModernStaticfileBuildpackStartCommandRegex))
    34  			Eventually(session).Should(Exit(0))
    35  
    36  			By("not providing a custom start command again, it reuses the previous custom start command")
    37  			session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName)
    38  			Eventually(session).Should(Say(`type:\s+web`))
    39  			Eventually(session).Should(Say(`start command:\s+%s && echo hello`, helpers.ModernStaticfileBuildpackStartCommandRegex))
    40  			Eventually(session).Should(Exit(0))
    41  		})
    42  	})
    43  
    44  	DescribeTable("resetting the start command",
    45  		func(startCommand string) {
    46  			helpers.WithHelloWorldApp(func(dir string) {
    47  				initialPush := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    48  					PushCommandName, appName,
    49  					"--start-command", fmt.Sprintf("%s && echo hello", helpers.ModernStaticfileBuildpackStartCommand))
    50  				Eventually(initialPush).Should(Exit(0))
    51  
    52  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    53  					PushCommandName, appName,
    54  					"--start-command", startCommand)
    55  				Eventually(session).Should(Say(`type:\s+web`))
    56  				Consistently(session).ShouldNot(Say(`start command:\s+%s && echo hello`, helpers.ModernStaticfileBuildpackStartCommandRegex))
    57  				Eventually(session).Should(Say(`start command:\s+%s`, helpers.ModernStaticfileBuildpackStartCommandRegex))
    58  				Eventually(session).Should(Exit(0))
    59  			})
    60  		},
    61  
    62  		Entry("the start command is set to 'default'", "default"),
    63  		Entry("the start command is set to 'null'", "null"),
    64  	)
    65  })