github.com/deiscc/workflow-e2e@v0.0.0-20181208071258-117299af888f/tests/cmd/builds/commands.go (about) 1 package builds 2 3 import ( 4 "time" 5 6 "github.com/deiscc/workflow-e2e/tests/cmd" 7 "github.com/deiscc/workflow-e2e/tests/model" 8 "github.com/deiscc/workflow-e2e/tests/settings" 9 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gbytes" 12 . "github.com/onsi/gomega/gexec" 13 ) 14 15 // The functions in this file implement SUCCESS CASES for commonly used `deis builds` subcommands. 16 // This allows each of these to be re-used easily in multiple contexts. 17 18 const ExampleImage = "deis/example-dockerfile-http" 19 20 // Create executes `deis builds:create` as the specified user. 21 func Create(user model.User, app model.App) { 22 createOrPull(user, app, "builds:create") 23 } 24 25 // Pull executes the `deis pull` shortcut as the specified user. 26 func Pull(user model.User, app model.App) { 27 createOrPull(user, app, "pull") 28 } 29 30 func createOrPull(user model.User, app model.App, command string) { 31 sess, err := cmd.Start("deis %s --app=%s %s", &user, command, app.Name, ExampleImage) 32 Expect(err).NotTo(HaveOccurred()) 33 Eventually(sess).Should(Say("Creating build...")) 34 Eventually(sess, settings.MaxEventuallyTimeout).Should(Exit(0)) 35 time.Sleep(10 * time.Second) 36 }