github.com/deiscc/workflow-e2e@v0.0.0-20181208071258-117299af888f/tests/releases_test.go (about)

     1  package tests
     2  
     3  import (
     4  	"github.com/deiscc/workflow-e2e/tests/cmd"
     5  	"github.com/deiscc/workflow-e2e/tests/cmd/apps"
     6  	"github.com/deiscc/workflow-e2e/tests/cmd/auth"
     7  	"github.com/deiscc/workflow-e2e/tests/cmd/builds"
     8  	"github.com/deiscc/workflow-e2e/tests/model"
     9  	"github.com/deiscc/workflow-e2e/tests/settings"
    10  
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  	. "github.com/onsi/gomega/gbytes"
    14  	. "github.com/onsi/gomega/gexec"
    15  )
    16  
    17  var _ = Describe("deis releases", func() {
    18  
    19  	Context("with an existing user", func() {
    20  
    21  		var user model.User
    22  
    23  		BeforeEach(func() {
    24  			user = auth.RegisterAndLogin()
    25  		})
    26  
    27  		AfterEach(func() {
    28  			auth.Cancel(user)
    29  		})
    30  
    31  		Context("who owns an existing app that has already been deployed", func() {
    32  
    33  			var app model.App
    34  
    35  			BeforeEach(func() {
    36  				app = apps.Create(user, "--no-remote")
    37  				builds.Create(user, app)
    38  			})
    39  
    40  			AfterEach(func() {
    41  				apps.Destroy(user, app)
    42  			})
    43  
    44  			Specify("that user can list that app's releases", func() {
    45  				sess, err := cmd.Start("deis releases:list -a %s", &user, app.Name)
    46  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Releases", app.Name))
    47  				Eventually(sess).Should(Say(`v1\s+.*\s+%s created initial release`, user.Username))
    48  				Expect(err).NotTo(HaveOccurred())
    49  				Eventually(sess).Should(Exit(0))
    50  			})
    51  
    52  			Specify("that user can get info on one of the app's releases", func() {
    53  				sess, err := cmd.Start("deis releases:info v2 -a %s", &user, app.Name)
    54  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Release v2", app.Name))
    55  				Eventually(sess).Should(Say(`config:\s+[\w-]+`))
    56  				Eventually(sess).Should(Say(`owner:\s+%s`, user.Username))
    57  				Eventually(sess).Should(Say(`summary:\s+%s \w+`, user.Username))
    58  				Expect(err).NotTo(HaveOccurred())
    59  				Eventually(sess).Should(Exit(0))
    60  			})
    61  
    62  			Context("and that app has three releases", func() {
    63  
    64  				BeforeEach(func() {
    65  					builds.Create(user, app)
    66  				})
    67  
    68  				Specify("that user can roll the application back to the second release", func() {
    69  					sess, err := cmd.Start("deis releases:rollback v2 -a %s", &user, app.Name)
    70  					Eventually(sess).Should(Say(`Rolling back to`))
    71  					Eventually(sess, settings.MaxEventuallyTimeout).Should(Say(`...done`))
    72  					Expect(err).NotTo(HaveOccurred())
    73  					Eventually(sess).Should(Exit(0))
    74  
    75  					sess, err = cmd.Start("deis releases:info v2 -a %s", &user, app.Name)
    76  					Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Release v2", app.Name))
    77  					Eventually(sess).Should(Say(`config:\s+[\w-]+`))
    78  					Eventually(sess).Should(Say(`owner:\s+%s`, user.Username))
    79  					Eventually(sess).Should(Say(`summary:\s+%s \w+`, user.Username))
    80  
    81  					// The updated date has to match a string like 2015-12-22T21:20:31Z:
    82  					Eventually(sess).Should(Say(`updated:\s+[\w\-\:]+Z`))
    83  					Eventually(sess).Should(Say(`uuid:\s+[0-9a-f\-]+`))
    84  					Expect(err).NotTo(HaveOccurred())
    85  					Eventually(sess).Should(Exit(0))
    86  				})
    87  
    88  			})
    89  
    90  		})
    91  
    92  	})
    93  
    94  })