github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/integration/v7/push/health_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 with health check type", func() {
    12  	var (
    13  		appName string
    14  	)
    15  
    16  	BeforeEach(func() {
    17  		appName = helpers.NewAppName()
    18  	})
    19  
    20  	Context("updating the application", func() {
    21  		BeforeEach(func() {
    22  			helpers.WithHelloWorldApp(func(dir string) {
    23  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "http")
    24  				Eventually(session).Should(Exit(0))
    25  
    26  				Eventually(helpers.CF("set-health-check", appName, "http", "--endpoint", "/some-endpoint")).Should(Exit(0))
    27  			})
    28  		})
    29  
    30  		When("setting the app to http health check type", func() {
    31  			It("should keep the health check http endpoint", func() {
    32  				helpers.WithHelloWorldApp(func(dir string) {
    33  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "http")).Should(Exit(0))
    34  				})
    35  
    36  				session := helpers.CF("get-health-check", appName)
    37  				Eventually(session).Should(Say("web\\s+http\\s+/"))
    38  				Eventually(session).Should(Exit(0))
    39  			})
    40  		})
    41  
    42  		When("setting the app to port health check type", func() {
    43  			It("should reset the health check http endpoint", func() {
    44  				helpers.WithHelloWorldApp(func(dir string) {
    45  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "port")).Should(Exit(0))
    46  				})
    47  
    48  				session := helpers.CF("get-health-check", appName)
    49  				Eventually(session).Should(Say("web\\s+port\\s+1"))
    50  				Eventually(session).Should(Exit(0))
    51  			})
    52  		})
    53  
    54  		When("setting the app to process health check type", func() {
    55  			It("should reset the health check http endpoint", func() {
    56  				helpers.WithHelloWorldApp(func(dir string) {
    57  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "process")).Should(Exit(0))
    58  				})
    59  
    60  				session := helpers.CF("get-health-check", appName)
    61  				Eventually(session).Should(Say("web\\s+process\\s+1"))
    62  				Eventually(session).Should(Exit(0))
    63  			})
    64  		})
    65  	})
    66  
    67  	Context("creating the application", func() {
    68  		When("setting a http health check type", func() {
    69  			It("should set the health check type to http and use the default health check endpoint", func() {
    70  				helpers.WithHelloWorldApp(func(dir string) {
    71  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "http")).Should(Exit(0))
    72  				})
    73  
    74  				session := helpers.CF("get-health-check", appName)
    75  				Eventually(session).Should(Say("web\\s+http\\s+/"))
    76  				Eventually(session).Should(Exit(0))
    77  			})
    78  		})
    79  
    80  		When("setting a port health check type", func() {
    81  			It("it should set the health check type to port", func() {
    82  				helpers.WithHelloWorldApp(func(dir string) {
    83  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "port")).Should(Exit(0))
    84  				})
    85  
    86  				session := helpers.CF("get-health-check", appName)
    87  				Eventually(session).Should(Say("web\\s+port"))
    88  				Eventually(session).Should(Exit(0))
    89  			})
    90  		})
    91  
    92  		When("setting a process health check type", func() {
    93  			It("it should set the health check type to process", func() {
    94  				helpers.WithHelloWorldApp(func(dir string) {
    95  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "process")).Should(Exit(0))
    96  				})
    97  
    98  				session := helpers.CF("get-health-check", appName)
    99  				Eventually(session).Should(Say("web\\s+process"))
   100  				Eventually(session).Should(Exit(0))
   101  			})
   102  		})
   103  	})
   104  })