Skip to content

Commit 0893509

Browse files
author
David Blackman
committed
extra params for old/new
1 parent 0948d9f commit 0893509

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/api-diff/api-diff.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ async function compareQuery({
5353
// otherwise run it against the old server
5454
const oldResponse = query.baselineResponse
5555
? ({ data: query.baselineResponse } as AxiosResponse<unknown>)
56-
: await runQuery(oldApiEnv, query, {
56+
: await runQuery(oldApiEnv, {
57+
...query,
58+
params: { ...query.params, ...oldApiEnv.extraParams },
59+
}, {
5760
timeout: argv.timeout,
5861
retries: argv.retries,
5962
}).catch((e) => {
@@ -62,7 +65,10 @@ async function compareQuery({
6265
});
6366

6467
const newResponse = newApiEnv
65-
? await runQuery(newApiEnv, query, {
68+
? await runQuery(newApiEnv, {
69+
...query,
70+
params: { ...query.params, ...newApiEnv.extraParams },
71+
}, {
6672
timeout: argv.timeout,
6773
retries: argv.retries,
6874
}).catch((e) => {

src/apiEnv.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* both for constructing the command line flags to specify one, and for interpreting the
55
* values of those command line flags into an ApiEnv object
66
*/
7+
import * as queryString from 'querystring';
78
import * as _ from 'lodash';
89
import yargs from 'yargs';
910
import * as os from 'os';
@@ -23,6 +24,7 @@ export interface ApiEnv {
2324
host: string;
2425
keyEnv: string;
2526
keyType?: string;
27+
extraParams?: Record<string, string>;
2628
}
2729

2830
type YargsOptionMapping = Record<string, yargs.Options>;
@@ -39,6 +41,12 @@ const apiEnvCommandLineOptions: YargsOptionMapping = {
3941
description:
4042
'Authorization key, if not specified will try to find one in the env or in ~/.api-keys.env',
4143
},
44+
extra_params: {
45+
type: 'array',
46+
default: [],
47+
description:
48+
'Extra static parameters that will be added to each query sent to this host, used for testing differences caused by slightly different query params',
49+
},
4250
};
4351

4452
/**
@@ -142,6 +150,9 @@ export function argvToApiEnv(
142150
if (argv.keyType) {
143151
apiEnv.keyType = argv.key_type;
144152
}
153+
if (argv.extra_params) {
154+
apiEnv.extraParams = queryString.parse(argv.extra_params.join('&')) as Record<string, string>;
155+
}
145156

146157
let aliasedHostEntry: ConfigHostEntry;
147158
_.forEach(config.hosts, (hostEntry: ConfigHostEntry, hostKey: string) => {

0 commit comments

Comments
 (0)