How to use configLoader method in stryker-parent

Best JavaScript code snippet using stryker-parent

ConfigLoader.test.ts

Source:ConfigLoader.test.ts Github

copy

Full Screen

1/*2 * Copyright 2020 NEM3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16import { expect } from '@oclif/test';17import 'mocha';18import { Account, NetworkType } from 'symbol-sdk';19import { ConfigAccount, PrivateKeySecurityMode } from '../../src/model';20import { BootstrapUtils, ConfigLoader, KeyName, Preset } from '../../src/service';21class ConfigLoaderMocked extends ConfigLoader {22 public generateAccount = (23 networkType: NetworkType,24 securityMode: PrivateKeySecurityMode,25 keyName: KeyName,26 oldAccount: ConfigAccount | undefined,27 privateKey: string | undefined,28 publicKey: string | undefined,29 ): ConfigAccount => super.generateAccount(networkType, securityMode, keyName, oldAccount, privateKey || 'a'.repeat(64), publicKey);30}31describe('ConfigLoader', () => {32 it('ConfigLoader loadPresetData testnet no assembly', async () => {33 const configLoader = new ConfigLoaderMocked();34 try {35 await configLoader.createPresetData({36 root: '.',37 preset: Preset.testnet,38 assembly: undefined,39 customPreset: undefined,40 customPresetObject: undefined,41 password: 'abc',42 });43 } catch (e) {44 expect(e.message).to.equal('Preset testnet requires assembly (-a, --assembly option). Possible values are: api, dual, peer');45 return;46 }47 expect(true).to.be.false;48 });49 it('ConfigLoader loadPresetData testnet assembly', async () => {50 const configLoader = new ConfigLoaderMocked();51 const presetData = await configLoader.createPresetData({52 root: '.',53 preset: Preset.testnet,54 assembly: 'dual',55 customPreset: undefined,56 customPresetObject: undefined,57 password: 'abc',58 });59 expect(presetData).to.not.be.undefined;60 });61 it('ConfigLoader loadPresetData bootstrap custom', async () => {62 const configLoader = new ConfigLoaderMocked();63 const presetData = await configLoader.createPresetData({64 root: '.',65 preset: Preset.bootstrap,66 assembly: undefined,67 customPreset: 'test/override-currency-preset.yml',68 customPresetObject: undefined,69 password: 'abcd',70 });71 expect(presetData).to.not.be.undefined;72 expect(presetData?.nemesis?.mosaics?.[0].accounts).to.be.eq(20);73 const yaml = BootstrapUtils.toYaml(presetData);74 expect(BootstrapUtils.fromYaml(yaml)).to.be.deep.eq(presetData);75 });76 it('ConfigLoader loadPresetData bootstrap custom too short!', async () => {77 const configLoader = new ConfigLoaderMocked();78 try {79 await configLoader.createPresetData({80 root: '.',81 preset: Preset.bootstrap,82 assembly: undefined,83 customPreset: 'test/override-currency-preset.yml',84 customPresetObject: undefined,85 password: 'abc',86 });87 } catch (e) {88 expect(e.message).eq('Password is too short. It should have at least 4 characters!');89 }90 });91 it('applyIndex', async () => {92 const configLoader = new ConfigLoaderMocked();93 const context = { $index: 10 };94 expect(configLoader.applyValueTemplate(context, 'hello')).to.be.eq('hello');95 expect(configLoader.applyValueTemplate(context, 'index')).to.be.eq('index');96 expect(configLoader.applyValueTemplate(context, '$index')).to.be.eq('$index');97 expect(configLoader.applyValueTemplate(context, '{{index}}')).to.be.eq('');98 expect(configLoader.applyValueTemplate(context, '{{$index}}')).to.be.eq('10');99 expect(configLoader.applyValueTemplate(context, '{{add $index 2}}')).to.be.eq('12');100 expect(configLoader.applyValueTemplate(context, '100.100.{{add $index 2}}')).to.be.eq('100.100.12');101 expect(configLoader.applyValueTemplate(context, '100.100.{{add $index 5}}')).to.be.eq('100.100.15');102 });103 it('expandServicesRepeat when repeat 3', async () => {104 const configLoader = new ConfigLoaderMocked();105 const services = [106 {107 repeat: 3,108 apiNodeName: 'api-node-{{$index}}',109 apiNodeHost: 'api-node-{{$index}}',110 apiNodeBrokerHost: 'api-node-broker-{{$index}}',111 name: 'rest-gateway-{{$index}}',112 description: 'catapult development network',113 databaseHost: 'db-{{$index}}',114 openPort: true,115 ipv4_address: '172.20.0.{{add $index 5}}',116 },117 ];118 const expandedServices = configLoader.expandServicesRepeat({}, services);119 const expectedExpandedServices = [120 {121 apiNodeName: 'api-node-0',122 apiNodeHost: 'api-node-0',123 apiNodeBrokerHost: 'api-node-broker-0',124 name: 'rest-gateway-0',125 description: 'catapult development network',126 databaseHost: 'db-0',127 openPort: true,128 ipv4_address: '172.20.0.5',129 },130 {131 apiNodeName: 'api-node-1',132 apiNodeHost: 'api-node-1',133 apiNodeBrokerHost: 'api-node-broker-1',134 name: 'rest-gateway-1',135 description: 'catapult development network',136 databaseHost: 'db-1',137 openPort: true,138 ipv4_address: '172.20.0.6',139 },140 {141 apiNodeName: 'api-node-2',142 apiNodeHost: 'api-node-2',143 apiNodeBrokerHost: 'api-node-broker-2',144 name: 'rest-gateway-2',145 description: 'catapult development network',146 databaseHost: 'db-2',147 openPort: true,148 ipv4_address: '172.20.0.7',149 },150 ];151 expect(expandedServices).to.be.deep.eq(expectedExpandedServices);152 });153 it('expandServicesRepeat when repeat 0', async () => {154 const configLoader = new ConfigLoaderMocked();155 const services = [156 {157 repeat: 0,158 apiNodeName: 'api-node-{{$index}}',159 apiNodeHost: 'api-node-{{$index}}',160 apiNodeBrokerHost: 'api-node-broker-{{$index}}',161 name: 'rest-gateway-{{$index}}',162 description: 'catapult development network',163 databaseHost: 'db-{{$index}}',164 openPort: true,165 ipv4_address: '172.20.0.{{add $index 5}}',166 },167 ];168 const expandedServices = configLoader.expandServicesRepeat({}, services);169 expect(expandedServices).to.be.deep.eq([]);170 });171 it('expandServicesRepeat when no repeat', async () => {172 const configLoader = new ConfigLoaderMocked();173 const services = [174 {175 apiNodeName: 'api-node-{{$index}}',176 apiNodeHost: 'api-node-{{$index}}',177 apiNodeBrokerHost: 'api-node-broker-{{$index}}',178 name: 'rest-gateway-{{$index}}',179 description: 'catapult development network',180 databaseHost: 'db-{{$index}}',181 openPort: true,182 ipv4_address: '172.20.0.{{add $index 5}}',183 },184 ];185 const expandedServices = configLoader.expandServicesRepeat({}, services);186 const expectedExpandedServices = [187 {188 apiNodeBrokerHost: 'api-node-broker-0',189 apiNodeHost: 'api-node-0',190 apiNodeName: 'api-node-0',191 databaseHost: 'db-0',192 description: 'catapult development network',193 ipv4_address: '172.20.0.5',194 name: 'rest-gateway-0',195 openPort: true,196 },197 ];198 expect(expandedServices).to.be.deep.eq(expectedExpandedServices);199 });200 it('applyValueTemplate when object', async () => {201 const configLoader = new ConfigLoaderMocked();202 const value = {203 _info: 'this file contains a list of api-node peers',204 knownPeers: [205 {206 publicKey: '46902d4a6136d43f8d78e3ab4494aee9b1da17886f6f0a698959714f96900bd6',207 endpoint: {208 host: 'api-node-0',209 port: 7900,210 },211 metadata: {212 name: 'api-node-0',213 roles: 'Api',214 },215 },216 ],217 };218 expect(configLoader.applyValueTemplate({}, value)).to.be.deep.eq(value);219 expect(configLoader.applyValueTemplate({}, BootstrapUtils.fromYaml(BootstrapUtils.toYaml(value)))).to.be.deep.eq(value);220 });221 it('applyValueTemplate when array', async () => {222 const configLoader = new ConfigLoaderMocked();223 const value = [224 {225 _info: 'this file contains a list of api-node peers',226 knownPeers: [227 {228 publicKey: '46902d4a6136d43f8d78e3ab4494aee9b1da17886f6f0a698959714f96900bd6',229 endpoint: {230 host: 'api-node-0',231 port: 7900,232 },233 metadata: {234 name: 'api-node-0',235 roles: 'Api',236 },237 },238 ],239 },240 ];241 expect(configLoader.applyValueTemplate({}, value)).to.be.deep.eq(value);242 expect(configLoader.applyValueTemplate({}, BootstrapUtils.fromYaml(BootstrapUtils.toYaml(value)))).to.be.deep.eq(value);243 });244 it('should migrated old addresses', () => {245 const configLoader = new ConfigLoaderMocked();246 const oldAddresses = BootstrapUtils.loadYaml('./test/addresses/addresses-old.yml', false);247 const newAddresses = BootstrapUtils.loadYaml('./test/addresses/addresses-new.yml', false);248 const addresses = configLoader.migrateAddresses(oldAddresses, NetworkType.TEST_NET);249 expect(addresses).to.be.deep.eq(newAddresses);250 });251 it('should migrated not migrate new addresses', () => {252 const configLoader = new ConfigLoaderMocked();253 const newAddresses = BootstrapUtils.loadYaml('./test/addresses/addresses-new.yml', false);254 const addresses = configLoader.migrateAddresses(newAddresses, NetworkType.TEST_NET);255 expect(addresses).to.be.deep.eq(newAddresses);256 });257 it('should generateAccount when old and new are different', () => {258 const configLoader = new ConfigLoader();259 const networkType = NetworkType.MIJIN_TEST;260 const securityMode = PrivateKeySecurityMode.ENCRYPT;261 const oldAccount = Account.generateNewAccount(networkType);262 const newAccount = Account.generateNewAccount(networkType);263 const account = configLoader.generateAccount(264 networkType,265 securityMode,266 KeyName.Main,267 {268 publicKey: oldAccount.publicKey,269 address: oldAccount.address.plain(),270 privateKey: oldAccount.privateKey,271 },272 newAccount.privateKey,273 newAccount.publicKey,274 );275 expect(account).deep.eq({276 publicKey: newAccount.publicKey,277 address: newAccount.address.plain(),278 privateKey: newAccount.privateKey,279 });280 });281 it('should generateAccount when old and new are different', () => {282 const configLoader = new ConfigLoader();283 const networkType = NetworkType.MIJIN_TEST;284 const securityMode = PrivateKeySecurityMode.ENCRYPT;285 const oldAccount = Account.generateNewAccount(networkType);286 const newAccount = Account.generateNewAccount(networkType);287 const account = configLoader.generateAccount(288 networkType,289 securityMode,290 KeyName.Main,291 {292 publicKey: oldAccount.publicKey,293 address: oldAccount.address.plain(),294 privateKey: oldAccount.privateKey,295 },296 newAccount.privateKey,297 newAccount.publicKey,298 );299 expect(account).deep.eq({300 publicKey: newAccount.publicKey,301 address: newAccount.address.plain(),302 privateKey: newAccount.privateKey,303 });304 });305 it('should generateAccount when old and new are same', () => {306 const configLoader = new ConfigLoader();307 const networkType = NetworkType.MIJIN_TEST;308 const securityMode = PrivateKeySecurityMode.ENCRYPT;309 const oldAccount = Account.generateNewAccount(networkType);310 const newAccount = oldAccount;311 const account = configLoader.generateAccount(312 networkType,313 securityMode,314 KeyName.Main,315 {316 publicKey: oldAccount.publicKey,317 address: oldAccount.address.plain(),318 privateKey: oldAccount.privateKey,319 },320 newAccount.privateKey,321 newAccount.publicKey,322 );323 expect(account).deep.eq({324 publicKey: newAccount.publicKey,325 address: newAccount.address.plain(),326 privateKey: newAccount.privateKey,327 });328 });329 it('should generateAccount when old and new are same, new no private eky', () => {330 const configLoader = new ConfigLoader();331 const networkType = NetworkType.MIJIN_TEST;332 const securityMode = PrivateKeySecurityMode.ENCRYPT;333 const oldAccount = Account.generateNewAccount(networkType);334 const newAccount = oldAccount;335 const account = configLoader.generateAccount(336 networkType,337 securityMode,338 KeyName.Main,339 {340 publicKey: oldAccount.publicKey,341 address: oldAccount.address.plain(),342 privateKey: oldAccount.privateKey,343 },344 undefined,345 newAccount.publicKey,346 );347 expect(account).deep.eq({348 publicKey: newAccount.publicKey,349 address: newAccount.address.plain(),350 privateKey: newAccount.privateKey,351 });352 });353 it('should generateAccount when old and new are same, old no private eky', () => {354 const configLoader = new ConfigLoader();355 const networkType = NetworkType.MIJIN_TEST;356 const securityMode = PrivateKeySecurityMode.ENCRYPT;357 const oldAccount = Account.generateNewAccount(networkType);358 const newAccount = oldAccount;359 const account = configLoader.generateAccount(360 networkType,361 securityMode,362 KeyName.Main,363 {364 publicKey: oldAccount.publicKey,365 address: oldAccount.address.plain(),366 },367 newAccount.privateKey,368 newAccount.publicKey,369 );370 expect(account).deep.eq({371 publicKey: newAccount.publicKey,372 address: newAccount.address.plain(),373 privateKey: newAccount.privateKey,374 });375 });376 it('should generateAccount when old and new are same, old private key', () => {377 const configLoader = new ConfigLoader();378 const networkType = NetworkType.MIJIN_TEST;379 const securityMode = PrivateKeySecurityMode.ENCRYPT;380 const oldAccount = Account.generateNewAccount(networkType);381 const newAccount = oldAccount;382 const account = configLoader.generateAccount(383 networkType,384 securityMode,385 KeyName.Main,386 {387 publicKey: oldAccount.publicKey,388 address: oldAccount.address.plain(),389 },390 undefined,391 newAccount.publicKey,392 );393 expect(account).deep.eq({394 publicKey: newAccount.publicKey,395 address: newAccount.address.plain(),396 });397 });398 it('should generateAccount when old and new are different, no private key new', () => {399 const configLoader = new ConfigLoader();400 const networkType = NetworkType.MIJIN_TEST;401 const securityMode = PrivateKeySecurityMode.ENCRYPT;402 const oldAccount = Account.generateNewAccount(networkType);403 const newAccount = Account.generateNewAccount(networkType);404 const account = configLoader.generateAccount(405 networkType,406 securityMode,407 KeyName.Main,408 {409 publicKey: oldAccount.publicKey,410 address: oldAccount.address.plain(),411 privateKey: oldAccount.privateKey,412 },413 undefined,414 newAccount.publicKey,415 );416 expect(account).deep.eq({417 publicKey: newAccount.publicKey,418 address: newAccount.address.plain(),419 });420 });421 it('should generateAccount when old and new are different. No new account', () => {422 const configLoader = new ConfigLoader();423 const networkType = NetworkType.MIJIN_TEST;424 const securityMode = PrivateKeySecurityMode.ENCRYPT;425 const oldAccount = Account.generateNewAccount(networkType);426 const account = configLoader.generateAccount(427 networkType,428 securityMode,429 KeyName.Main,430 {431 publicKey: oldAccount.publicKey,432 address: oldAccount.address.plain(),433 privateKey: oldAccount.privateKey,434 },435 undefined,436 undefined,437 );438 expect(account).deep.eq({439 publicKey: oldAccount.publicKey,440 address: oldAccount.address.plain(),441 privateKey: oldAccount.privateKey,442 });443 });444 it('should generateAccount when old and new are different. No new account. Old without private', () => {445 const configLoader = new ConfigLoader();446 const networkType = NetworkType.MIJIN_TEST;447 const securityMode = PrivateKeySecurityMode.ENCRYPT;448 const oldAccount = Account.generateNewAccount(networkType);449 const account = configLoader.generateAccount(450 networkType,451 securityMode,452 KeyName.Main,453 {454 publicKey: oldAccount.publicKey,455 address: oldAccount.address.plain(),456 },457 undefined,458 undefined,459 );460 expect(account).deep.eq({461 publicKey: oldAccount.publicKey,462 address: oldAccount.address.plain(),463 });464 });465 it('should generateAccount brand new', () => {466 const configLoader = new ConfigLoader();467 const networkType = NetworkType.MIJIN_TEST;468 const securityMode = PrivateKeySecurityMode.ENCRYPT;469 const account = configLoader.generateAccount(networkType, securityMode, KeyName.Main, undefined, undefined, undefined);470 expect(account.address).not.undefined;471 expect(account.privateKey).not.undefined;472 expect(account.privateKey).not.undefined;473 });474 it('should generateAccount brand new on remote', () => {475 const configLoader = new ConfigLoader();476 const networkType = NetworkType.MIJIN_TEST;477 const securityMode = PrivateKeySecurityMode.PROMPT_MAIN_TRANSPORT;478 const account = configLoader.generateAccount(networkType, securityMode, KeyName.Remote, undefined, undefined, undefined);479 expect(account.address).not.undefined;480 expect(account.privateKey).not.undefined;481 expect(account.privateKey).not.undefined;482 });483 it('should generateAccount brand new on voting', () => {484 const configLoader = new ConfigLoader();485 const networkType = NetworkType.MIJIN_TEST;486 const securityMode = PrivateKeySecurityMode.PROMPT_MAIN;487 const account = configLoader.generateAccount(networkType, securityMode, KeyName.Voting, undefined, undefined, undefined);488 expect(account.address).not.undefined;489 expect(account.privateKey).not.undefined;490 expect(account.privateKey).not.undefined;491 });492 it('should generateAccount raise error new', () => {493 const configLoader = new ConfigLoader();494 const networkType = NetworkType.MIJIN_TEST;495 const securityMode = PrivateKeySecurityMode.PROMPT_MAIN;496 expect(() => configLoader.generateAccount(networkType, securityMode, KeyName.Main, undefined, undefined, undefined)).throw;497 });498 it('should generateAccount raise error new', () => {499 const configLoader = new ConfigLoader();500 const networkType = NetworkType.MIJIN_TEST;501 const securityMode = PrivateKeySecurityMode.PROMPT_MAIN_TRANSPORT;502 expect(() => configLoader.generateAccount(networkType, securityMode, KeyName.Transport, undefined, undefined, undefined)).throw;503 });504 it('should generateAccount raise error new', () => {505 const configLoader = new ConfigLoader();506 const networkType = NetworkType.MIJIN_TEST;507 const securityMode = PrivateKeySecurityMode.PROMPT_ALL;508 expect(() => configLoader.generateAccount(networkType, securityMode, KeyName.Remote, undefined, undefined, undefined)).throw;509 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const configLoader = require('stryker-parent').configLoader;2configLoader.load('test');3const configLoader = require('stryker-parent').configLoader;4configLoader.load('test');5const configLoader = require('stryker-parent').configLoader;6configLoader.load('test');7const configLoader = require('stryker-parent').configLoader;8configLoader.load('test');9const configLoader = require('stryker-parent').configLoader;10configLoader.load('test');11const configLoader = require('stryker-parent').configLoader;12configLoader.load('test');13const configLoader = require('stryker-parent').configLoader;14configLoader.load('test');15const configLoader = require('stryker-parent').configLoader;16configLoader.load('test');17const configLoader = require('stryker-parent').configLoader;18configLoader.load('test');19const configLoader = require('stryker-parent').configLoader;20configLoader.load('test');21const configLoader = require('stryker-parent').configLoader;22configLoader.load('test');23const configLoader = require('stryker-parent').configLoader;24configLoader.load('test');25const configLoader = require('stryker-parent').configLoader;26configLoader.load('test');

Full Screen

Using AI Code Generation

copy

Full Screen

1const configLoader = require('stryker-parent').configLoader;2const config = configLoader.loadConfig();3module.exports = function(config) {4 config.set({5 });6};

Full Screen

Using AI Code Generation

copy

Full Screen

1var configLoader = require('stryker-parent').configLoader;2var config = configLoader.load();3var configLoader = require('stryker-parent').configLoader;4var config = configLoader.load();5var configLoader = require('stryker-parent').configLoader;6var config = configLoader.load();7var configLoader = require('stryker-parent').configLoader;8var config = configLoader.load();9var configLoader = require('stryker-parent').configLoader;10var config = configLoader.load();11var configLoader = require('stryker-parent').configLoader;12var config = configLoader.load();13var configLoader = require('stryker-parent').configLoader;14var config = configLoader.load();15var configLoader = require('stryker-parent').configLoader;16var config = configLoader.load();17var configLoader = require('stryker-parent').configLoader;18var config = configLoader.load();19var configLoader = require('stryker-parent').configLoader;20var config = configLoader.load();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful