github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/integration/v7/push/app_start_timeout_flag_test.go (about)

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"os"
     7  	"path/filepath"
     8  
     9  	"github.com/LukasHeimann/cloudfoundrycli/v8/integration/helpers"
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  	. "github.com/onsi/gomega/gexec"
    13  )
    14  
    15  var _ = Describe("push with health check timeout flag", func() {
    16  	var (
    17  		appName            string
    18  		manifestFilePath   string
    19  		tempDir            string
    20  		healthCheckTimeout = "42"
    21  	)
    22  
    23  	BeforeEach(func() {
    24  		appName = helpers.NewAppName()
    25  		var err error
    26  		tempDir, err = ioutil.TempDir("", "create-manifest")
    27  		Expect(err).ToNot(HaveOccurred())
    28  
    29  		manifestFilePath = filepath.Join(tempDir, fmt.Sprintf("%s_manifest.yml", appName))
    30  	})
    31  
    32  	AfterEach(func() {
    33  		os.RemoveAll(tempDir)
    34  	})
    35  
    36  	When("the app exists with an http health check", func() {
    37  		BeforeEach(func() {
    38  			helpers.WithHelloWorldApp(func(dir string) {
    39  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    40  					PushCommandName, appName, "--health-check-type", "http", "--endpoint", "/",
    41  				)
    42  
    43  				Eventually(session).Should(Exit(0))
    44  			})
    45  		})
    46  
    47  		It("correctly updates the health check timeout", func() {
    48  			helpers.WithHelloWorldApp(func(dir string) {
    49  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    50  					PushCommandName, appName, "--app-start-timeout", healthCheckTimeout,
    51  				)
    52  
    53  				Eventually(session).Should(Exit(0))
    54  			})
    55  
    56  			session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: tempDir},
    57  				"create-app-manifest", appName)
    58  			Eventually(session).Should(Exit(0))
    59  
    60  			createdFile, err := ioutil.ReadFile(manifestFilePath)
    61  			Expect(err).ToNot(HaveOccurred())
    62  
    63  			Expect(createdFile).To(MatchRegexp("---"))
    64  			Expect(createdFile).To(MatchRegexp("applications:"))
    65  			Expect(createdFile).To(MatchRegexp("name: %s", appName))
    66  			Expect(createdFile).To(MatchRegexp("processes"))
    67  			Expect(createdFile).To(MatchRegexp("timeout: %s", healthCheckTimeout))
    68  		})
    69  
    70  	})
    71  
    72  })