Skip to content
Prev Previous commit
Next Next commit
add some client tests
  • Loading branch information
Avital-Fine committed Mar 1, 2022
commit 7403892bfa48c6a8ff45870f4f16c531b6f81b62
21 changes: 21 additions & 0 deletions packages/client/lib/cluster/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import * as BRPOP from '../commands/BRPOP';
import * as BRPOPLPUSH from '../commands/BRPOPLPUSH';
import * as BZPOPMAX from '../commands/BZPOPMAX';
import * as BZPOPMIN from '../commands/BZPOPMIN';
import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH';
import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS';
import * as CLUSTER_INFO from '../commands/CLUSTER_INFO';
import * as CLUSTER_MYID from '../commands/CLUSTER_MYID';
import * as CLUSTER_RESET from '../commands/CLUSTER_RESET';
import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG';
import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH';
import * as COPY from '../commands/COPY';
import * as DECR from '../commands/DECR';
import * as DECRBY from '../commands/DECRBY';
Expand Down Expand Up @@ -199,6 +206,20 @@ export default {
bzPopMax: BZPOPMAX,
BZPOPMIN,
bzPopMin: BZPOPMIN,
CLUSTER_BUMPEPOCH,
clusterBumpEpoch: CLUSTER_BUMPEPOCH,
CLUSTER_COUNT_FAILURE_REPORTS,
clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS,
CLUSTER_INFO,
clusterInfo: CLUSTER_INFO,
CLUSTER_MYID,
clusterMyId: CLUSTER_MYID,
CLUSTER_RESET,
clusterReset: CLUSTER_RESET,
CLUSTER_SAVECONFIG,
clusterSaveConfig: CLUSTER_SAVECONFIG,
CLUSTER_SET_CONFIG_EPOCH,
clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH,
COPY,
copy: COPY,
DECR,
Expand Down
10 changes: 9 additions & 1 deletion packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_BUMPEPOCH';

describe('CLUSTER BUMPEPOCH', () => {
describe.only('CLUSTER BUMPEPOCH', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['CLUSTER', 'BUMPEPOCH']
);
});

testUtils.testWithCluster('cluster.clusterBumpEpoch', async cluster => {
assert.equal(
typeof await cluster.clusterBumpEpoch(),
'string'
);
}, GLOBAL.CLUSTERS.OPEN);
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_COUNT-FAILURE-REPORTS';

describe('CLUSTER COUNT-FAILURE-REPORTS', () => {
describe.only('CLUSTER COUNT-FAILURE-REPORTS', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('1'),
['CLUSTER', 'COUNT-FAILURE-REPORTS', '1']
);
});

testUtils.testWithCluster('cluster.clusterCountFailureReports', async cluster => {
const id: string = await cluster.clusterMyId();
assert.equal(
await cluster.clusterCountFailureReports(id),
0
);
}, GLOBAL.CLUSTERS.OPEN);
});
10 changes: 9 additions & 1 deletion packages/client/lib/commands/CLUSTER_INFO.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './CLUSTER_INFO';

describe('CLUSTER INFO', () => {
describe.only('CLUSTER INFO', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
Expand Down Expand Up @@ -43,4 +44,11 @@ describe('CLUSTER INFO', () => {
}
);
});

testUtils.testWithCluster('cluster.clusterInfo', async cluster => {
assert.notEqual(
await cluster.clusterInfo(),
null
);
}, GLOBAL.CLUSTERS.OPEN);
});
10 changes: 9 additions & 1 deletion packages/client/lib/commands/CLUSTER_MYID.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_MYID';

describe('CLUSTER MYID', () => {
describe.only('CLUSTER MYID', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['CLUSTER', 'MYID']
);
});

testUtils.testWithCluster('cluster.clusterMyId', async cluster => {
assert.notEqual(
await cluster.clusterMyId(),
null
);
}, GLOBAL.CLUSTERS.OPEN);
});
10 changes: 9 additions & 1 deletion packages/client/lib/commands/CLUSTER_RESET.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_RESET';

describe('CLUSTER RESET', () => {
describe.only('CLUSTER RESET', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
Expand All @@ -24,4 +25,11 @@ describe('CLUSTER RESET', () => {
);
});
});

testUtils.testWithCluster('cluster.clusterReset', async cluster => {
assert.equal(
await cluster.clusterReset('SOFT'),
'OK'
);
}, GLOBAL.CLUSTERS.OPEN);
});
10 changes: 9 additions & 1 deletion packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_SAVECONFIG';

describe('CLUSTER SAVECONFIG', () => {
describe.only('CLUSTER SAVECONFIG', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['CLUSTER', 'SAVECONFIG']
);
});

testUtils.testWithCluster('cluster.clusterSaveConfig', async cluster => {
assert.equal(
await cluster.clusterSaveConfig(),
'OK'
);
}, GLOBAL.CLUSTERS.OPEN);
});
14 changes: 13 additions & 1 deletion packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_SET-CONFIG-EPOCH';

describe('CLUSTER SET-CONFIG-EPOCH', () => {
describe.only('CLUSTER SET-CONFIG-EPOCH', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(0),
['CLUSTER', 'SET-CONFIG-EPOCH', '0']
);
});

testUtils.testWithCluster('cluster.clusterSetConfigEpoch', async cluster => {
try {
assert.equal(
await cluster.clusterSetConfigEpoch(1),
'OK'
);
} catch (ReplyError) {
//?
}
}, GLOBAL.CLUSTERS.OPEN);
});