@@ -1483,9 +1483,12 @@ var tests = map[string]map[string][]func(d *Deployment){}
1483
1483
1484
1484
// Describe remembers a certain test. The actual registration in
1485
1485
// Ginkgo happens in DefineTests, ordered such that all tests with the
1486
- // same "deployment" string are defined on after the after with the
1486
+ // same "deployment" string are defined one after the after with the
1487
1487
// given "describe" string.
1488
1488
//
1489
+ // An empty deployment is valid. Those tests will run after the ones
1490
+ // which use deployments. Their callback is passed a nil Deployment.
1491
+ //
1489
1492
// When "describe" is already unique, "what" can be left empty.
1490
1493
func Describe (deployment , describe , what string , f func (d * Deployment )) bool {
1491
1494
group := tests [deployment ]
@@ -1509,12 +1512,26 @@ func Describe(deployment, describe, what string, f func(d *Deployment)) bool {
1509
1512
1510
1513
// DefineTests must be called to register all tests defined so far via Describe.
1511
1514
func DefineTests () {
1512
- for deploymentName , group := range tests {
1515
+ all := allDeployments [:]
1516
+ for deploymentName := range tests {
1517
+ if ! haveDeployment (all , deploymentName ) {
1518
+ all = append (all , deploymentName )
1519
+ }
1520
+ }
1521
+
1522
+ for _ , deploymentName := range all {
1523
+ group , ok := tests [deploymentName ]
1524
+ if ! ok {
1525
+ continue
1526
+ }
1513
1527
deploymentName := deploymentName
1514
1528
for describe , funcs := range group {
1515
1529
funcs := funcs
1516
1530
ginkgo .Describe (describe , func () {
1517
- deployment := EnsureDeployment (deploymentName )
1531
+ var deployment * Deployment
1532
+ if deploymentName != "" {
1533
+ deployment = EnsureDeployment (deploymentName )
1534
+ }
1518
1535
for _ , f := range funcs {
1519
1536
f (deployment )
1520
1537
}
@@ -1523,6 +1540,15 @@ func DefineTests() {
1523
1540
}
1524
1541
}
1525
1542
1543
+ func haveDeployment (all []string , one string ) bool {
1544
+ for _ , a := range all {
1545
+ if a == one {
1546
+ return true
1547
+ }
1548
+ }
1549
+ return false
1550
+ }
1551
+
1526
1552
// waitForPodDeletion returns an error if it takes too long for the pod to fully terminate.
1527
1553
func waitForPodDeletion (c * Cluster , pod v1.Pod ) error {
1528
1554
return wait .PollImmediate (2 * time .Second , time .Minute , func () (bool , error ) {
0 commit comments