@@ -54,8 +54,8 @@ class TestClientProvider {
54
54
55
55
@test
56
56
public async getStartClusterSets ( ) {
57
- await this . expectInstallations ( [ "a1" , " a2", "a3" ] , await this . provider . getStartClusterSets ( { } as User , { } as Workspace , { } as WorkspaceInstance ) , "default case" ) ;
58
- this . expectInstallations ( [ "a1" , "a2" , "a3" , "con1" ] , await this . provider . getStartClusterSets ( {
57
+ await this . expectInstallations ( [ [ " a2", "a3" ] ] , await this . provider . getStartClusterSets ( { } as User , { } as Workspace , { } as WorkspaceInstance ) , "default case" ) ;
58
+ await this . expectInstallations ( [ [ "con1" ] , [ "a2" , "a3" ] ] , await this . provider . getStartClusterSets ( {
59
59
rolesOrPermissions : [ "new-workspace-cluster" ]
60
60
} as User , { } as Workspace , { } as WorkspaceInstance ) , "new workspace cluster" ) ;
61
61
}
@@ -102,13 +102,27 @@ class TestClientProvider {
102
102
expect ( constraintInverseMoreResources ( clusters , { getsMoreResources : true } as ExtendedUser , { } as Workspace , { } as WorkspaceInstance ) . map ( c => c . name ) , "inverse more resources" ) . to . be . eql ( [ "b1" ] ) ;
103
103
}
104
104
105
- private async expectInstallations ( expected : string [ ] , actual : IWorkspaceClusterStartSet , msg : string ) {
105
+ private async expectInstallations ( expectedSets : string [ ] [ ] , actual : IWorkspaceClusterStartSet , msg : string ) {
106
106
const a : string [ ] = [ ] ;
107
107
for await ( const c of actual ) {
108
108
a . push ( c . installation ) ;
109
109
}
110
110
111
- expect ( a . sort ( ) , msg ) . to . be . eql ( expected ) ;
111
+ // we check:
112
+ // - the order of returned sets
113
+ // - identical content of said sets
114
+ // - NOT the order of clusters within a set
115
+ let i = 0 ;
116
+ for ( ; i < expectedSets . length ; i ++ ) {
117
+ const eSet = expectedSets [ i ] ;
118
+ const aSet = a . splice ( 0 , eSet . length ) ;
119
+ expect ( aSet . sort ( ) , `returned set does not match (${ msg } )` ) . to . be . eql ( eSet . sort ( ) ) ;
120
+ }
121
+
122
+ const eOverage = expectedSets . slice ( i ) . reduce ( ( p , c ) => [ ...p , ...c ] , [ ] ) ;
123
+ const aOverage = a ;
124
+ expect ( eOverage , `missing some cluster(s)/sets (${ msg } )` ) . to . be . empty ;
125
+ expect ( aOverage , `got too many cluster(s)/sets (${ msg } )` ) . to . be . empty ;
112
126
}
113
127
114
128
}
0 commit comments