Skip to content

Commit bca7112

Browse files
committed
Fix tests to reflect changes in odo watch command execution
Signed-off-by: Denis Golovin <[email protected]>
1 parent 47c0b5e commit bca7112

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/odo.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface OpenShiftObject extends QuickPickItem {
4949
contextPath?: Uri;
5050
path?: string;
5151
builderImage?: BuilderImage;
52+
iconPath?: Uri;
5253
}
5354

5455
export enum ContextType {
@@ -404,8 +405,6 @@ class OdoModel {
404405
array.splice(array.indexOf(item), 1);
405406
this.pathToObject.delete(item.path);
406407
this.contextToObject.delete(item.contextPath.fsPath);
407-
const ps = this.objectToProcess.get(item);
408-
if (ps) ps.kill('SIGINT');
409408
}
410409

411410
public deleteContext(context: string): void {

src/openshift/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ export class Component extends OpenShiftItem {
501501
commands.executeCommand('openshift.component.watch.showLog', component.contextPath.fsPath);
502502
}
503503
} else {
504-
const process :ChildProcess = await Component.odo.spawn(Command.watchComponent(component.getParent().getParent().getName(), component.getParent().getName(), component.getName()), component.contextPath.fsPath);
504+
const process: ChildProcess = await Component.odo.spawn(Command.watchComponent(component.getParent().getParent().getName(), component.getParent().getName(), component.getName()), component.contextPath.fsPath);
505505
Component.addWatchSession(component, process);
506506
process.on('exit', () => {
507507
Component.removeWatchSession(component);

src/watch.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export class WatchSessionsView implements TreeDataProvider<string>, Disposable {
7373
return {
7474
label: WatchSessionsView.sessions.get(element).label,
7575
collapsibleState: TreeItemCollapsibleState.None,
76-
contextValue: 'openshift.watch.process'
76+
contextValue: 'openshift.watch.process',
77+
iconPath: WatchSessionsView.odoctl.getOpenShiftObjectByContext(element).iconPath
7778
};
7879
}
7980

test/unit/openshift/component.test.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as vscode from 'vscode';
88
import * as chai from 'chai';
99
import * as sinonChai from 'sinon-chai';
1010
import * as sinon from 'sinon';
11+
import { ChildProcess } from 'child_process';
1112
import { TestItem } from './testOSItem';
1213
import { OdoImpl, ContextType } from '../../../src/odo';
1314
import { Command } from "../../../src/odo/command";
@@ -19,6 +20,7 @@ import OpenShiftItem from '../../../src/openshift/openshiftItem';
1920
import pq = require('proxyquire');
2021
import globby = require('globby');
2122

23+
2224
const {expect} = chai;
2325
chai.use(sinonChai);
2426

@@ -43,6 +45,7 @@ suite('OpenShift/Component', () => {
4345
let Component: any;
4446
let fetchTag: sinon.SinonStub;
4547
let commandStub: sinon.SinonStub;
48+
let spawnStub: sinon.SinonStub;
4649

4750
setup(() => {
4851
sandbox = sinon.createSandbox();
@@ -51,6 +54,7 @@ suite('OpenShift/Component', () => {
5154
Component = pq('../../../src/openshift/component', {}).Component;
5255
termStub = sandbox.stub(OdoImpl.prototype, 'executeInTerminal');
5356
execStub = sandbox.stub(OdoImpl.prototype, 'execute').resolves({ stdout: "" });
57+
spawnStub = sandbox.stub(OdoImpl.prototype, 'spawn');
5458
sandbox.stub(OdoImpl.prototype, 'getServices');
5559
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([]);
5660
sandbox.stub(OdoImpl.prototype, 'getApplications').resolves([]);
@@ -1122,15 +1126,17 @@ suite('OpenShift/Component', () => {
11221126
});
11231127

11241128
test('calls the correct odo command w/ context', async () => {
1129+
const cpStub = {on: sinon.stub()} as any as ChildProcess;
1130+
spawnStub.resolves(cpStub);
11251131
await Component.watch(componentItem);
1126-
1127-
expect(termStub).calledOnceWith(Command.watchComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
1132+
expect(spawnStub).calledOnceWith(Command.watchComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
11281133
});
11291134

11301135
test('calls the correct odo command w/o context', async () => {
1136+
const cpStub = {on: sinon.stub()} as any as ChildProcess;
1137+
spawnStub.resolves(cpStub);
11311138
await Component.watch(null);
1132-
1133-
expect(termStub).calledOnceWith(Command.watchComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
1139+
expect(spawnStub).calledOnceWith(Command.watchComponent(projectItem.getName(), appItem.getName(), componentItem.getName()));
11341140
});
11351141
});
11361142

0 commit comments

Comments
 (0)