github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/push/docker_test.go (about)

     1  package push
     2  
     3  import (
     4  	"os"
     5  
     6  	"code.cloudfoundry.org/cli/integration/helpers"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  	. "github.com/onsi/gomega/gexec"
    12  )
    13  
    14  var _ = Describe("pushing a docker image", func() {
    15  	var (
    16  		appName string
    17  	)
    18  
    19  	BeforeEach(func() {
    20  		appName = helpers.NewAppName()
    21  	})
    22  
    23  	Describe("a public docker image", func() {
    24  		Describe("app existence", func() {
    25  			Context("when the app does not exist", func() {
    26  				It("creates the app", func() {
    27  					session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage)
    28  					Eventually(session).Should(Say("Getting app info\\.\\.\\."))
    29  					Eventually(session).Should(Say("Creating app with these attributes\\.\\.\\."))
    30  					Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
    31  					Eventually(session).Should(Say("\\s+docker image:\\s+%s", PublicDockerImage))
    32  					Eventually(session).Should(Say("Mapping routes\\.\\.\\."))
    33  					helpers.ConfirmStagingLogs(session)
    34  					Eventually(session).Should(Say("Waiting for app to start\\.\\.\\."))
    35  					Eventually(session).Should(Say("requested state:\\s+started"))
    36  					Eventually(session).Should(Exit(0))
    37  
    38  					session = helpers.CF("app", appName)
    39  					Eventually(session).Should(Say("name:\\s+%s", appName))
    40  					Eventually(session).Should(Exit(0))
    41  				})
    42  			})
    43  
    44  			Context("when the app exists", func() {
    45  				BeforeEach(func() {
    46  					Eventually(helpers.CF(PushCommandName, appName, "-o", PublicDockerImage)).Should(Exit(0))
    47  				})
    48  
    49  				It("updates the app", func() {
    50  					session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage)
    51  					Eventually(session).Should(Say("Getting app info\\.\\.\\."))
    52  					Eventually(session).Should(Say("Updating app with these attributes\\.\\.\\."))
    53  					Eventually(session).Should(Say("\\s+name:\\s+%s", appName))
    54  					Eventually(session).Should(Say("\\s+docker image:\\s+%s", PublicDockerImage))
    55  					Eventually(session).Should(Say("Mapping routes\\.\\.\\."))
    56  					Eventually(session).Should(Say("Waiting for app to start\\.\\.\\."))
    57  					Eventually(session).Should(Say("requested state:\\s+started"))
    58  					Eventually(session).Should(Exit(0))
    59  
    60  					session = helpers.CF("app", appName)
    61  					Eventually(session).Should(Say("name:\\s+%s", appName))
    62  					Eventually(session).Should(Exit(0))
    63  				})
    64  			})
    65  		})
    66  	})
    67  
    68  	Describe("private docker image", func() {
    69  		var (
    70  			privateDockerImage    string
    71  			privateDockerUsername string
    72  			privateDockerPassword string
    73  		)
    74  
    75  		BeforeEach(func() {
    76  			privateDockerImage = os.Getenv("CF_INT_DOCKER_IMAGE")
    77  			privateDockerUsername = os.Getenv("CF_INT_DOCKER_USERNAME")
    78  			privateDockerPassword = os.Getenv("CF_INT_DOCKER_PASSWORD")
    79  
    80  			if privateDockerImage == "" || privateDockerUsername == "" || privateDockerPassword == "" {
    81  				Skip("CF_INT_DOCKER_IMAGE, CF_INT_DOCKER_USERNAME, or CF_INT_DOCKER_PASSWORD is not set")
    82  			}
    83  		})
    84  
    85  		Context("when CF_DOCKER_PASSWORD is set", func() {
    86  			It("push the docker image with those credentials", func() {
    87  				session := helpers.CustomCF(
    88  					helpers.CFEnv{
    89  						EnvVars: map[string]string{"CF_DOCKER_PASSWORD": privateDockerPassword},
    90  					},
    91  					PushCommandName, "--docker-username", privateDockerUsername, "--docker-image", privateDockerImage, appName,
    92  				)
    93  				Eventually(session).Should(Say("Getting app info\\.\\.\\."))
    94  				Eventually(session).Should(Say("Creating app with these attributes\\.\\.\\."))
    95  				Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
    96  				Eventually(session).Should(Say("\\s+docker image:\\s+%s", privateDockerImage))
    97  				Eventually(session).Should(Say("Mapping routes\\.\\.\\."))
    98  				helpers.ConfirmStagingLogs(session)
    99  				Eventually(session).Should(Say("Waiting for app to start\\.\\.\\."))
   100  				Eventually(session).Should(Say("requested state:\\s+started"))
   101  				Eventually(session).Should(Exit(0))
   102  			})
   103  		})
   104  
   105  	})
   106  })