github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/integration/shared/global/global_suite_test.go (about)

     1  package global
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
     8  	"code.cloudfoundry.org/cli/integration/helpers"
     9  
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  
    13  	"testing"
    14  )
    15  
    16  const (
    17  	CFEventuallyTimeout   = 300 * time.Second
    18  	CFConsistentlyTimeout = 500 * time.Millisecond
    19  )
    20  
    21  var (
    22  	// Per Test Level
    23  	homeDir       string
    24  	ReadOnlyOrg   string
    25  	ReadOnlySpace string
    26  )
    27  
    28  func TestGlobal(t *testing.T) {
    29  	RegisterFailHandler(Fail)
    30  	reporters := []Reporter{}
    31  
    32  	honeyCombReporter := helpers.GetHoneyCombReporter("Global Suite")
    33  
    34  	if honeyCombReporter != nil {
    35  		reporters = append(reporters, honeyCombReporter)
    36  	}
    37  
    38  	RunSpecsWithDefaultAndCustomReporters(t, "Global Suite", reporters)
    39  }
    40  
    41  var _ = SynchronizedBeforeSuite(func() []byte {
    42  	GinkgoWriter.Write([]byte("==============================Global FIRST Node Synchronized Before Each=============================="))
    43  	// Ginkgo Globals
    44  	SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    45  	SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    46  
    47  	// Setup common environment variables
    48  	helpers.TurnOffColors()
    49  
    50  	helpers.SetupSynchronizedSuite(func() {
    51  		helpers.EnableFeatureFlag("diego_docker")
    52  
    53  		if helpers.IsVersionMet(ccversion.MinVersionShareServiceV3) {
    54  			helpers.EnableFeatureFlag("service_instance_sharing")
    55  		}
    56  	})
    57  
    58  	ReadOnlyOrg, ReadOnlySpace = helpers.SetupReadOnlyOrgAndSpace()
    59  
    60  	GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each=============================="))
    61  	return nil
    62  }, func(_ []byte) {
    63  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    64  	if GinkgoParallelNode() != 1 {
    65  		Fail("Test suite cannot run in parallel")
    66  	}
    67  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    68  })
    69  
    70  var _ = BeforeEach(func() {
    71  	GinkgoWriter.Write([]byte("==============================Global Before Each=============================="))
    72  	homeDir = helpers.SetHomeDir()
    73  	helpers.SetAPI()
    74  	GinkgoWriter.Write([]byte("==============================End of Global Before Each=============================="))
    75  })
    76  
    77  var _ = AfterEach(func() {
    78  	GinkgoWriter.Write([]byte("==============================Global After Each=============================="))
    79  	helpers.DestroyHomeDir(homeDir)
    80  	GinkgoWriter.Write([]byte("==============================End of Global After Each=============================="))
    81  })