@@ -31,6 +31,10 @@ import {type ClusterChecks} from '../../../src/core/cluster_checks.js';
31
31
import { type K8ClientConfigMaps } from '../../../src/core/kube/k8_client/resources/config_map/k8_client_config_maps.js' ;
32
32
import { InjectTokens } from '../../../src/core/dependency_injection/inject_tokens.js' ;
33
33
import { K8Client } from '../../../src/core/kube/k8_client/k8_client.js' ;
34
+ import { ConsensusNode } from '../../../src/core/model/consensus_node.js' ;
35
+ import { ConsensusNode } from '../../../src/core/model/consensus_node.js' ;
36
+ import * as cluster from 'node:cluster' ;
37
+ import { NamespaceName } from '../../../src/core/kube/resources/namespace/namespace_name.js' ;
34
38
35
39
const testName = 'network-cmd-unit' ;
36
40
const argv = getDefaultArgv ( ) ;
@@ -188,47 +192,49 @@ describe('NetworkCommand unit tests', () => {
188
192
} ) ;
189
193
190
194
it ( 'Should use prepare config correctly for all clusters' , async ( ) => {
191
- const common = path . join ( 'test' , 'data' , 'test-values.yaml' ) ;
192
- const values1 = path . join ( 'test' , 'data' , 'test-values1.yaml' ) ;
193
- const values2 = path . join ( 'test' , 'data' , 'test-values2.yaml' ) ;
194
- argv [ flags . networkDeploymentValuesFile . name ] = `${ common } ,cluster-1=${ values1 } ,cluster-1=${ values2 } \`` ;
195
- argv [ flags . chartDirectory . name ] = 'test-directory' ;
196
- argv [ flags . force . name ] = true ;
195
+ try {
196
+ const common = path . join ( 'test' , 'data' , 'test-values.yaml' ) ;
197
+ const values1 = path . join ( 'test' , 'data' , 'test-values1.yaml' ) ;
198
+ const values2 = path . join ( 'test' , 'data' , 'test-values2.yaml' ) ;
199
+ argv [ flags . networkDeploymentValuesFile . name ] = `${ common } ,cluster=${ values1 } ,cluster=${ values2 } \`` ;
200
+ argv [ flags . chartDirectory . name ] = 'test-directory' ;
201
+ argv [ flags . force . name ] = true ;
197
202
198
- const task = sinon . stub ( ) ;
203
+ const task = sinon . stub ( ) ;
199
204
200
- const networkCommand = new NetworkCommand ( opts ) ;
201
- const config = await networkCommand . prepareConfig ( task , argv ) ;
202
-
203
- expect ( config . valuesArgMap ) . to . not . empty ;
204
- expect ( config . valuesArgMap [ 'cluster-1' ] ) . to . not . empty ;
205
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'solo-deployment/values.yaml' ) ) . to . not . equal ( - 1 ) ;
206
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'values.yaml' ) ) . to . not . equal ( - 1 ) ;
207
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values1.yaml' ) ) . to . not . equal ( - 1 ) ;
208
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values2.yaml' ) ) . to . not . equal ( - 1 ) ;
209
- expect ( config . valuesArgMap [ 'cluster-2' ] ) . to . not . empty ;
210
- expect ( config . valuesArgMap [ 'cluster-2' ] . indexOf ( 'solo-deployment/values.yaml' ) ) . to . not . equal ( - 1 ) ;
211
- expect ( config . valuesArgMap [ 'cluster-2' ] . indexOf ( 'values.yaml' ) ) . to . not . equal ( - 1 ) ;
212
- expect ( config . valuesArgMap [ 'cluster-2' ] . indexOf ( 'test-values1.yaml' ) ) . to . equal ( - 1 ) ;
213
- expect ( config . valuesArgMap [ 'cluster-2' ] . indexOf ( 'test-values2.yaml' ) ) . to . equal ( - 1 ) ;
214
-
215
- // chart values file should precede the values file passed in the command
216
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'solo-deployment/values.yaml' ) ) . to . be . lt (
217
- config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values1.yaml' ) ,
218
- ) ;
219
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'solo-deployment/values.yaml' ) ) . to . be . lt (
220
- config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values2.yaml' ) ,
221
- ) ;
205
+ sinon
206
+ . stub ( NetworkCommand . prototype , 'getConsensusNodes' )
207
+ . returns ( [ new ConsensusNode ( 'node1' , 0 , 'solo-e2e' , 'cluster' , 'context-1' ) ] ) ;
208
+ const networkCommand = new NetworkCommand ( opts ) ;
209
+ const config = await networkCommand . prepareConfig ( task , argv ) ;
210
+
211
+ expect ( config . valuesArgMap ) . to . not . empty ;
212
+ expect ( config . valuesArgMap [ 'cluster' ] ) . to . not . empty ;
213
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'solo-deployment/values.yaml' ) ) . to . not . equal ( - 1 ) ;
214
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'values.yaml' ) ) . to . not . equal ( - 1 ) ;
215
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values1.yaml' ) ) . to . not . equal ( - 1 ) ;
216
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values2.yaml' ) ) . to . not . equal ( - 1 ) ;
217
+
218
+ // chart values file should precede the values file passed in the command
219
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'solo-deployment/values.yaml' ) ) . to . be . lt (
220
+ config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values1.yaml' ) ,
221
+ ) ;
222
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'solo-deployment/values.yaml' ) ) . to . be . lt (
223
+ config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values2.yaml' ) ,
224
+ ) ;
222
225
223
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'values.yaml' ) ) . to . be . lt (
224
- config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values1.yaml' ) ,
225
- ) ;
226
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values1.yaml' ) ) . to . be . lt (
227
- config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values2.yaml' ) ,
228
- ) ;
229
- expect ( config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'values.yaml' ) ) . to . be . lt (
230
- config . valuesArgMap [ 'cluster-1' ] . indexOf ( 'test-values2.yaml' ) ,
231
- ) ;
226
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'values.yaml' ) ) . to . be . lt (
227
+ config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values1.yaml' ) ,
228
+ ) ;
229
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values1.yaml' ) ) . to . be . lt (
230
+ config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values2.yaml' ) ,
231
+ ) ;
232
+ expect ( config . valuesArgMap [ 'cluster' ] . indexOf ( 'values.yaml' ) ) . to . be . lt (
233
+ config . valuesArgMap [ 'cluster' ] . indexOf ( 'test-values2.yaml' ) ,
234
+ ) ;
235
+ } finally {
236
+ sinon . restore ( ) ;
237
+ }
232
238
} ) ;
233
239
} ) ;
234
240
} ) ;
0 commit comments