Skip to content

Commit b8fb11e

Browse files
committed
Fix unit test errrors
Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 6a03210 commit b8fb11e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/openshift/component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export class Component extends OpenShiftItem {
104104
}
105105

106106
@vsCommand('openshift.component.create')
107+
@clusterRequired()
108+
@selectTargetApplication(
109+
'In which Application you want to create a Component'
110+
)
107111
static async create(application: OpenShiftApplication): Promise<string> {
108112
if (!application) return null;
109113

@@ -115,11 +119,11 @@ export class Component extends OpenShiftItem {
115119

116120
let command: Promise<string>;
117121
if (componentSource.label === SourceTypeChoice.GIT.label) {
118-
command = Promise.resolve(commands.executeCommand('openshift.component.createFromGit', application));
122+
command = Component.createFromGit(application);
119123
} else if (componentSource.label === SourceTypeChoice.BINARY.label) {
120-
command = Promise.resolve(commands.executeCommand('openshift.component.createFromBinary', application));
124+
command = Component.createFromBinary(application);
121125
} else if (componentSource.label === SourceTypeChoice.LOCAL.label) {
122-
command = Promise.resolve(commands.executeCommand('openshift.component.createFromLocal', application));
126+
command = Component.createFromLocal(application);
123127
}
124128
return command.catch((err) => Promise.reject(new VsCommandError(`Failed to create Component with error '${err}'`, 'Failed to create Component with error')));
125129
}

test/unit/openshift/catalog.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
import * as chai from 'chai';
77
import * as sinonChai from 'sinon-chai';
88
import * as sinon from 'sinon';
9-
import { OdoImpl } from '../../../src/odo';
9+
import { ContextType, OdoImpl } from '../../../src/odo';
1010
import { Command } from '../../../src/odo/command';
1111
import { Catalog } from '../../../src/openshift/catalog';
1212
import { Platform } from '../../../src/util/platform';
13+
import { TestItem } from './testOSItem';
1314

1415
const {expect} = chai;
1516
chai.use(sinonChai);
@@ -20,21 +21,22 @@ suite('OpenShift/Catalog', () => {
2021

2122
setup(() => {
2223
sandbox = sinon.createSandbox();
24+
sandbox.stub(OdoImpl.prototype, 'getClusters').resolves([new TestItem(undefined, 'cluster', ContextType.CLUSTER)]);
2325
execStub = sandbox.stub(OdoImpl.prototype, 'executeInTerminal').resolves();
2426
});
2527

2628
teardown(() => {
2729
sandbox.restore();
2830
});
2931

30-
test('listComponents calls odo catalog list components', () => {
31-
Catalog.listComponents();
32+
test('listComponents calls odo catalog list components', async () => {
33+
await Promise.resolve(Catalog.listComponents());
3234

3335
expect(execStub).calledOnceWith(Command.listCatalogComponents());
3436
});
3537

36-
test('listServices calls odo catalog list services', () => {
37-
Catalog.listServices();
38+
test('listServices calls odo catalog list services', async () => {
39+
await Promise.resolve(Catalog.listServices());
3840

3941
expect(execStub).calledOnceWith(Command.listCatalogServices(), Platform.getUserHomePath());
4042
});

0 commit comments

Comments
 (0)