github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+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  	CFConsistentlyTimeout = 500 * time.Millisecond
    17  	RealIsolationSegment  = "persistent_isolation_segment"
    18  	DockerImage           = "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, "Isolated 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  	helpers.EnableDockerSupport()
    48  	ReadOnlyOrg, ReadOnlySpace = helpers.SetupReadOnlyOrgAndSpace()
    49  })
    50  
    51  var _ = SynchronizedAfterSuite(func() {
    52  	helpers.SetAPI()
    53  	helpers.LoginCF()
    54  	helpers.QuickDeleteOrg(ReadOnlyOrg)
    55  }, func() {
    56  })
    57  
    58  var _ = BeforeEach(func() {
    59  	homeDir = helpers.SetHomeDir()
    60  	apiURL, skipSSLValidation = helpers.SetAPI()
    61  })
    62  
    63  var _ = AfterEach(func() {
    64  	helpers.DestroyHomeDir(homeDir)
    65  })
    66  
    67  var foundDefaultDomain string
    68  
    69  func defaultSharedDomain() string {
    70  	// TODO: Move this into helpers when other packages need it, figure out how
    71  	// to cache cuz this is a wacky call otherwise
    72  	if foundDefaultDomain == "" {
    73  		session := helpers.CF("domains")
    74  		Eventually(session).Should(Exit(0))
    75  
    76  		regex, err := regexp.Compile(`(.+?)\s+shared`)
    77  		Expect(err).ToNot(HaveOccurred())
    78  
    79  		matches := regex.FindStringSubmatch(string(session.Out.Contents()))
    80  		Expect(matches).To(HaveLen(2))
    81  
    82  		foundDefaultDomain = matches[1]
    83  	}
    84  	return foundDefaultDomain
    85  }
    86  
    87  func setupCF(org string, space string) {
    88  	helpers.LoginCF()
    89  	if org != ReadOnlyOrg && space != ReadOnlySpace {
    90  		helpers.CreateOrgAndSpace(org, space)
    91  	}
    92  	helpers.TargetOrgAndSpace(org, space)
    93  }