github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/integration/experimental/experimental_suite_test.go (about) 1 package experimental 2 3 import ( 4 "regexp" 5 "testing" 6 "time" 7 8 "github.com/liamawhite/cli-with-i18n/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 CFConsistentlyTimeout = 500 * time.Millisecond 17 RealIsolationSegment = "persistent_isolation_segment" 18 PublicDockerImage = "cloudfoundry/diego-docker-app-custom" 19 ) 20 21 var ( 22 // Suite Level 23 apiURL string 24 skipSSLValidation string 25 ReadOnlyOrg string 26 ReadOnlySpace string 27 28 // Per Test Level 29 homeDir string 30 ) 31 32 func TestIsolated(t *testing.T) { 33 RegisterFailHandler(Fail) 34 RunSpecs(t, "Experimental Integration Suite") 35 } 36 37 var _ = SynchronizedBeforeSuite(func() []byte { 38 return nil 39 }, func(_ []byte) { 40 // Ginkgo Globals 41 SetDefaultEventuallyTimeout(CFEventuallyTimeout) 42 SetDefaultConsistentlyDuration(CFConsistentlyTimeout) 43 44 // Setup common environment variables 45 helpers.TurnOffColors() 46 47 // Enable Experimental Flag 48 helpers.TurnOnExperimental() 49 50 helpers.EnableDockerSupport() 51 ReadOnlyOrg, ReadOnlySpace = helpers.SetupReadOnlyOrgAndSpace() 52 }) 53 54 var _ = SynchronizedAfterSuite(func() { 55 helpers.SetAPI() 56 helpers.LoginCF() 57 helpers.QuickDeleteOrg(ReadOnlyOrg) 58 }, func() { 59 }) 60 61 var _ = BeforeEach(func() { 62 homeDir = helpers.SetHomeDir() 63 apiURL, skipSSLValidation = helpers.SetAPI() 64 }) 65 66 var _ = AfterEach(func() { 67 helpers.DestroyHomeDir(homeDir) 68 }) 69 70 var foundDefaultDomain string 71 72 func defaultSharedDomain() string { 73 // TODO: Move this into helpers when other packages need it, figure out how 74 // to cache cuz this is a wacky call otherwise 75 if foundDefaultDomain == "" { 76 session := helpers.CF("domains") 77 Eventually(session).Should(Exit(0)) 78 79 regex, err := regexp.Compile(`(.+?)\s+shared`) 80 Expect(err).ToNot(HaveOccurred()) 81 82 matches := regex.FindStringSubmatch(string(session.Out.Contents())) 83 Expect(matches).To(HaveLen(2)) 84 85 foundDefaultDomain = matches[1] 86 } 87 return foundDefaultDomain 88 } 89 90 func setupCF(org string, space string) { 91 helpers.LoginCF() 92 if org != ReadOnlyOrg && space != ReadOnlySpace { 93 helpers.CreateOrgAndSpace(org, space) 94 } 95 helpers.TargetOrgAndSpace(org, space) 96 }