Skip to content

Commit 7d3403b

Browse files
committed
remove all hardcoded usage of 'capture' mode
1 parent 7fac73a commit 7d3403b

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/Pythagora.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Pythagora {
3333
this.idSeq = 0;
3434
this.requests = {};
3535
this.testingRequests = {};
36-
this.loggingEnabled = this.mode === 'capture';
36+
this.loggingEnabled = this.mode === MODES.capture;
3737
//todo move all global vars to tempVars
3838
this.tempVars = {};
3939

src/helpers/redis.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const MODES = require('../const/modes.json');
12
let net = require('net');
23

34
const CHUNK_SIZE = 1024;
@@ -15,7 +16,7 @@ module.exports = class RedisInterceptor {
1516
this.listenSocket = net.createServer(connection => {
1617
connection.on('data', data => {
1718

18-
if (this.mode === 'capture') {
19+
if (this.mode === MODES.capture) {
1920
this.forwardData(connection, data, true);
2021
} else if (this.mode === 'test') {
2122

src/utils/argumentsCheck.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
const AVAILABLE_MODES = ['capture', 'test'];
1+
const MODES = require('../const/modes.json');
22
const args = require('./getArgs.js');
33
const { logAndExit } = require('./cmdPrint.js');
44

5+
const AVAILABLE_MODES = Object.keys(MODES);
6+
57
if (!args.mode) {
68
if (args.rerun_all_failed || args.test_id) {
79
console.log('Mode not provided. Setting to "test".');
810
args.mode = 'test';
911
} else {
10-
console.log('Mode not provided. Defaulting to "capture".');
11-
args.mode = 'capture';
12+
console.log(`Mode not provided. Defaulting to "${MODES.capture}".`);
13+
args.mode = MODES.capture;
1214
}
1315
} else if (!AVAILABLE_MODES.includes(args.mode)) {
1416
logAndExit(`Mode "${args.mode}" not recognized. Available modes are: ${AVAILABLE_MODES.join(', ')}`);
@@ -18,8 +20,8 @@ if (args.rerun_all_failed && args.mode !== 'test') logAndExit(`Flag --rerun_all_
1820
if (args.test_id && args.mode !== 'test') logAndExit(`Flag --test-id allowed only in "--mode test"`);
1921
if (args.rerun_all_failed && args.test_id) logAndExit(`Not allowed to set flags --rerun_all_failed and --test-id at same time.`);
2022

21-
if (args.pick && args.mode !== 'capture') logAndExit(`Flag --pick allowed only in "--mode capture"`);
22-
if (args.ignore && args.mode !== 'capture') logAndExit(`Flag --ignore allowed only in "--mode capture"`);
23+
if (args.pick && args.mode !== MODES.capture) logAndExit(`Flag --pick allowed only in "--mode ${MODES.capture}"`);
24+
if (args.ignore && args.mode !== MODES.capture) logAndExit(`Flag --ignore allowed only in "--mode ${MODES.capture}"`);
2325

2426
console.log(`Running "${process.env.PYTHAGORA_CONFIG}" using Pythagora in "${args.mode.toUpperCase()}" mode.`);
2527

0 commit comments

Comments
 (0)