Skip to content

Commit 24f1e69

Browse files
committed
Add Test command in App Explorer view and palette
This PR fixes #1974. Signed-off-by: Denis Golovin [email protected]
1 parent 9572948 commit 24f1e69

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

package.json

+20
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,18 @@
781781
"command": "openshift.explorer.addCluster.openCrcAddClusterPage",
782782
"title": "Open Add CRC Cluster Wizard",
783783
"category": "OpenShift"
784+
},
785+
{
786+
"command": "openshift.component.test",
787+
"title": "Test",
788+
"category": "OpenShift"
789+
},
790+
{
791+
"command": "openshift.component.test.palette",
792+
"title": "Test Component",
793+
"category": "OpenShift"
784794
}
795+
785796
],
786797
"keybindings": [
787798
{
@@ -859,6 +870,10 @@
859870
"command": "openshift.component.create",
860871
"when": "view == openshiftProjectExplorer"
861872
},
873+
{
874+
"command": "openshift.component.test",
875+
"when": "false"
876+
},
862877
{
863878
"command": "openshift.component.createFromRootWorkspaceFolder",
864879
"when": "view == workbench.view.explorer"
@@ -1237,6 +1252,11 @@
12371252
"when": "view == openshiftProjectExplorer && viewItem == component",
12381253
"group": "c4@5"
12391254
},
1255+
{
1256+
"command": "openshift.component.test",
1257+
"when": "view == openshiftProjectExplorer && viewItem == component",
1258+
"group": "c4@6"
1259+
},
12401260
{
12411261
"command": "openshift.component.delete",
12421262
"when": "view == openshiftProjectExplorer && viewItem == componentNoContext",

src/odo/command.ts

+4
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ export class Command {
256256
return `odo create ${type}:${version} ${name} ${version?'--s2i':''} --binary ${binary} --app ${app} --project ${project} --context ${context}`;
257257
}
258258

259+
static testComponent() {
260+
return 'odo test --show-log';
261+
};
262+
259263
@verbose
260264
static createService(
261265
project: string,

src/openshift/component.ts

+14
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,20 @@ export class Component extends OpenShiftItem {
920920
);
921921
}
922922

923+
@vsCommand('openshift.component.test', true)
924+
@selectTargetComponent(
925+
'Select an Application',
926+
'Select a Component you want to debug (showing only Components pushed to the cluster)',
927+
(value: OpenShiftComponent) => value.contextValue === ContextType.COMPONENT_PUSHED && value.kind === ComponentKind.DEVFILE
928+
)
929+
static async test(component: OpenShiftComponent): Promise<string | void> {
930+
if (!component) return null;
931+
if (component.kind === ComponentKind.S2I) {
932+
return 'Test command does not supported for S2I components';
933+
}
934+
await Component.odo.executeInTerminal(Command.testComponent(), component.contextPath.fsPath, `OpenShift: Test '${component.getName()}' Component`);
935+
}
936+
923937
@vsCommand('openshift.component.import')
924938
static async import(component: OpenShiftObject): Promise<string | null> {
925939
const prjName = component.getParent().getParent().getName();

0 commit comments

Comments
 (0)