github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/integration/isolated/isolated_suite_test.go (about) 1 package isolated 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 ) 17 18 var ( 19 // Suite Level 20 apiURL string 21 skipSSLValidation string 22 ReadOnlyOrg string 23 ReadOnlySpace string 24 25 // Per Test Level 26 homeDir string 27 ) 28 29 func TestIsolated(t *testing.T) { 30 RegisterFailHandler(Fail) 31 RunSpecs(t, "Isolated Integration Suite") 32 } 33 34 var _ = SynchronizedBeforeSuite(func() []byte { 35 return nil 36 }, func(_ []byte) { 37 // Ginkgo Globals 38 SetDefaultEventuallyTimeout(CFEventuallyTimeout) 39 40 // Setup common environment variables 41 helpers.TurnOffColors() 42 43 ReadOnlyOrg, ReadOnlySpace = helpers.SetupReadOnlyOrgAndSpace() 44 }) 45 46 var _ = BeforeEach(func() { 47 homeDir = helpers.SetHomeDir() 48 apiURL, skipSSLValidation = helpers.SetAPI() 49 }) 50 51 var _ = AfterEach(func() { 52 helpers.DestroyHomeDir(homeDir) 53 }) 54 55 var foundDefaultDomain string 56 57 func defaultSharedDomain() string { 58 // TODO: Move this into helpers when other packages need it, figure out how 59 // to cache cuz this is a wacky call otherwise 60 if foundDefaultDomain == "" { 61 session := helpers.CF("domains") 62 Eventually(session).Should(Exit(0)) 63 64 regex, err := regexp.Compile(`(.+?)\s+shared`) 65 Expect(err).ToNot(HaveOccurred()) 66 67 matches := regex.FindStringSubmatch(string(session.Out.Contents())) 68 Expect(matches).To(HaveLen(2)) 69 70 foundDefaultDomain = matches[1] 71 } 72 return foundDefaultDomain 73 } 74 75 func setupCF(org string, space string) { 76 helpers.LoginCF() 77 if org != ReadOnlyOrg && space != ReadOnlySpace { 78 helpers.CreateOrgAndSpace(org, space) 79 } 80 helpers.TargetOrgAndSpace(org, space) 81 }