Skip to content

Commit 40200a7

Browse files
committed
fixed some unit test cases
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent d6ca20e commit 40200a7

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

test/unit/commands/network.test.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ describe('NetworkCommand unit tests', () => {
155155

156156
it('Install function is called with expected parameters', async () => {
157157
const networkCommand = new NetworkCommand(opts);
158-
sinon.stub(networkCommand, 'getConsensusNodes').resolves([]);
159-
sinon.stub(networkCommand, 'getContexts').resolves([]);
158+
sinon.stub(networkCommand, 'getConsensusNodes').returns([]);
159+
sinon.stub(networkCommand, 'getContexts').returns([]);
160160
await networkCommand.deploy(argv);
161161

162162
expect(opts.chartManager.install.args[0][0].name).to.equal(constants.SOLO_TEST_CLUSTER);
@@ -168,19 +168,23 @@ describe('NetworkCommand unit tests', () => {
168168
});
169169

170170
it('Should use local chart directory', async () => {
171-
argv[flags.chartDirectory.name] = 'test-directory';
172-
argv[flags.force.name] = true;
173-
174-
const networkCommand = new NetworkCommand(opts);
175-
sinon.stub(networkCommand, 'getConsensusNodes').resolves([]);
176-
sinon.stub(networkCommand, 'getContexts').resolves([]);
177-
await networkCommand.deploy(argv);
178-
expect(opts.chartManager.install.args[0][0].name).to.equal(constants.SOLO_TEST_CLUSTER);
179-
expect(opts.chartManager.install.args[0][1]).to.equal(constants.SOLO_DEPLOYMENT_CHART);
180-
expect(opts.chartManager.install.args[0][2]).to.equal(
181-
path.join(ROOT_DIR, 'test-directory', constants.SOLO_DEPLOYMENT_CHART),
182-
);
183-
expect(opts.chartManager.install.args[0][3]).to.equal(version.SOLO_CHART_VERSION);
171+
try {
172+
argv[flags.chartDirectory.name] = 'test-directory';
173+
argv[flags.force.name] = true;
174+
175+
sinon.stub(NetworkCommand.prototype, 'getConsensusNodes').returns([]);
176+
sinon.stub(NetworkCommand.prototype, 'getContexts').returns([]);
177+
const networkCommand = new NetworkCommand(opts);
178+
await networkCommand.deploy(argv);
179+
expect(opts.chartManager.install.args[0][0].name).to.equal(constants.SOLO_TEST_CLUSTER);
180+
expect(opts.chartManager.install.args[0][1]).to.equal(constants.SOLO_DEPLOYMENT_CHART);
181+
expect(opts.chartManager.install.args[0][2]).to.equal(
182+
path.join(ROOT_DIR, 'test-directory', constants.SOLO_DEPLOYMENT_CHART),
183+
);
184+
expect(opts.chartManager.install.args[0][3]).to.equal(version.SOLO_CHART_VERSION);
185+
} finally {
186+
sinon.restore();
187+
}
184188
});
185189

186190
it('Should use prepare config correctly for all clusters', async () => {

test/unit/core/certificate_manager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ describe('Certificate Manager', () => {
2323
let certificateManager: CertificateManager;
2424

2525
before(() => {
26+
resetForTest();
2627
sinon.stub(K8Client.prototype, 'init').returns(k8InitSpy);
2728
sinon.stub(K8ClientSecrets.prototype, 'create').resolves(true);
28-
resetForTest();
2929
argv[flags.namespace.name] = 'namespace';
3030
const configManager: ConfigManager = container.resolve(InjectTokens.ConfigManager);
3131
configManager.update(argv);

0 commit comments

Comments
 (0)