Skip to content

Commit 4a69f34

Browse files
committed
Fix unit test errors in test/unit/extension.test.ts
Fix fake function call to return correct jason when extension search for odo components in workspace folders. Now it uses `odo descirbe` which returns json for kind `Component` instead of kind `List`. Json return for listing components also updated to use `s2iComponents` and `devfileComponents` instead of `items` field Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 665eda5 commit 4a69f34

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

test/unit/extension.test.ts

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,26 @@ chai.use(sinonChai);
2525
function genComponentJson(p: string, a: string, n: string, c: string ): string {
2626
return `
2727
{
28-
"kind": "List",
28+
"kind": "Component",
2929
"apiVersion": "odo.openshift.io/v1alpha1",
30-
"metadata": {},
31-
"items": [
32-
{
33-
"kind": "Component",
34-
"apiVersion": "odo.openshift.io/v1alpha1",
35-
"metadata": {
36-
"name": "${n}",
37-
"namespace": "${p}",
38-
"creationTimestamp": null
39-
},
40-
"spec": {
41-
"app": "app1",
42-
"type": "nodejs:10",
43-
"sourceType": "git",
44-
"ports": [
45-
"8080/TCP"
46-
]
47-
},
48-
"status": {
49-
"context": "${c.replace(/\\/g,'\\\\')}",
50-
"state": "Not Pushed"
51-
}
52-
}
53-
]
54-
}`
30+
"metadata": {
31+
"name": "${n}",
32+
"namespace": "${p}",
33+
"creationTimestamp": null
34+
},
35+
"spec": {
36+
"app": "app1",
37+
"type": "nodejs:10",
38+
"sourceType": "git",
39+
"ports": [
40+
"8080/TCP"
41+
]
42+
},
43+
"status": {
44+
"context": "${c.replace(/\\/g,'\\\\')}",
45+
"state": "Not Pushed"
46+
}
47+
}`;
5548
}
5649

5750
suite('openshift connector Extension', () => {
@@ -71,15 +64,15 @@ suite('openshift connector Extension', () => {
7164
uri: comp2Uri, index: 1, name: 'comp2'
7265
}]);
7366
// eslint-disable-next-line @typescript-eslint/require-await
74-
sandbox.stub(OdoImpl.prototype, 'execute').callsFake(async (cmd: string)=> {
67+
sandbox.stub(OdoImpl.prototype, 'execute').callsFake(async (cmd: string, cwd: string)=> {
7568
if (cmd.includes('version')) {
7669
return { error: undefined, stdout: "Server: https://api.crc.testing:6443", stderr: '' };
7770
}
7871

79-
if(cmd.includes('--path')) {
72+
if(cmd.includes('describe')) {
8073
const args = cmd.split(' ');
8174
const name = args[3].substr(args[3].lastIndexOf(path.sep)+1);
82-
return { error: undefined, stdout: genComponentJson('myproject', 'app1', name, args[3]), stderr: '' };
75+
return { error: undefined, stdout: genComponentJson('myproject', 'app1', name, args[3]), stderr: '', cwd };
8376
}
8477

8578
if (cmd.includes('list --app')) {
@@ -88,7 +81,8 @@ suite('openshift connector Extension', () => {
8881
"kind": "List",
8982
"apiVersion": "odo.openshift.io/v1alpha1",
9083
"metadata": {},
91-
"items": []
84+
"s2iComponents": [],
85+
"devfileComponents": []
9286
}`, stderr: ''}
9387
}
9488
return { error: undefined, stdout: '', stderr: ''};

0 commit comments

Comments
 (0)