github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/push/push_suite_test.go (about) 1 package push 2 3 import ( 4 "regexp" 5 "testing" 6 "time" 7 8 "code.cloudfoundry.org/cli/integration/helpers" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 const ( 15 CFEventuallyTimeout = 300 * time.Second 16 RealIsolationSegment = "persistent_isolation_segment" 17 PushCommandName = "v2-push" 18 PublicDockerImage = "cloudfoundry/diego-docker-app-custom" 19 ) 20 21 var ( 22 // Suite Level 23 organization string 24 space string 25 foundDefaultDomain string 26 27 // Per Test Level 28 homeDir string 29 ) 30 31 func TestPush(t *testing.T) { 32 RegisterFailHandler(Fail) 33 RunSpecs(t, "Push Integration Suite") 34 } 35 36 var _ = SynchronizedBeforeSuite(func() []byte { 37 return nil 38 }, func(_ []byte) { 39 // Ginkgo Globals 40 SetDefaultEventuallyTimeout(CFEventuallyTimeout) 41 SetDefaultConsistentlyDuration(CFEventuallyTimeout) 42 // Setup common environment variables 43 helpers.TurnOffColors() 44 45 homeDir = helpers.SetHomeDir() 46 helpers.SetAPI() 47 helpers.LoginCF() 48 organization = helpers.NewOrgName() 49 helpers.CreateOrg(organization) 50 helpers.TargetOrg(organization) 51 helpers.CreateSpace("empty-space") 52 helpers.DestroyHomeDir(homeDir) 53 }) 54 55 var _ = SynchronizedAfterSuite(func() { 56 helpers.SetAPI() 57 helpers.LoginCF() 58 helpers.QuickDeleteOrg(organization) 59 }, func() { 60 }) 61 62 var _ = BeforeEach(func() { 63 homeDir = helpers.SetHomeDir() 64 helpers.SetAPI() 65 space = helpers.NewSpaceName() 66 setupCF(organization, space) 67 }) 68 69 var _ = AfterEach(func() { 70 helpers.QuickDeleteSpace(space) 71 helpers.DestroyHomeDir(homeDir) 72 }) 73 74 func defaultSharedDomain() string { 75 // TODO: Move this into helpers when other packages need it, figure out how 76 // to cache cuz this is a wacky call otherwise 77 if foundDefaultDomain == "" { 78 session := helpers.CF("domains") 79 Eventually(session).Should(Exit(0)) 80 81 regex, err := regexp.Compile(`(.+?)\s+shared`) 82 Expect(err).ToNot(HaveOccurred()) 83 84 matches := regex.FindStringSubmatch(string(session.Out.Contents())) 85 Expect(matches).To(HaveLen(2)) 86 87 foundDefaultDomain = matches[1] 88 } 89 return foundDefaultDomain 90 } 91 92 func setupCF(org string, space string) { 93 helpers.LoginCF() 94 helpers.TargetOrg(org) 95 helpers.CreateSpace(space) 96 helpers.TargetOrgAndSpace(org, space) 97 }