Skip to content

Commit 1fd7ee1

Browse files
committed
Fix unit tests errors
Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 8069313 commit 1fd7ee1

File tree

1 file changed

+0
-208
lines changed

1 file changed

+0
-208
lines changed

test/unit/openshift/component.test.ts

Lines changed: 0 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,214 +1436,6 @@ suite('OpenShift/Component', () => {
14361436

14371437
});
14381438

1439-
suite('import', () => {
1440-
1441-
const componentResult = {
1442-
error: null,
1443-
stderr: '',
1444-
stdout: JSON.stringify({
1445-
apiVersion: 'v1',
1446-
items: [
1447-
{
1448-
apiVersion: 'apps.openshift.io/v1',
1449-
kind: 'DeploymentConfig',
1450-
metadata: {
1451-
annotations: {
1452-
'app.kubernetes.io/component-source-type': 'git',
1453-
'app.openshift.io/vcs-uri': 'https://github.com/sclorg/nodejs-ex'
1454-
},
1455-
labels: {
1456-
app: 'app',
1457-
'app.kubernetes.io/instance': 'comp4',
1458-
'app.kubernetes.io/name': 'nodejs',
1459-
'app.kubernetes.io/part-of': 'app',
1460-
'app.openshift.io/runtime-version': 'latest'
1461-
}
1462-
},
1463-
spec: {
1464-
template: {
1465-
spec: {
1466-
containers: [
1467-
{
1468-
volumeMounts: [
1469-
{
1470-
mountPath: '/path',
1471-
name: 'storage1-app-pvc-zeclz-volume'
1472-
}
1473-
]
1474-
}
1475-
],
1476-
volumes: [
1477-
{
1478-
name: 'storage1-app-pvc-zeclz-volume',
1479-
persistentVolumeClaim: {
1480-
claimName: 'storage1-app-pvc'
1481-
}
1482-
}
1483-
]
1484-
}
1485-
},
1486-
test: false,
1487-
}
1488-
}
1489-
]
1490-
})
1491-
};
1492-
const bcResult = {
1493-
error: null,
1494-
stderr: '',
1495-
stdout: JSON.stringify({
1496-
apiVersion: 'build.openshift.io/v1',
1497-
kind: 'BuildConfig',
1498-
spec: {
1499-
source: {
1500-
git: {
1501-
ref: 'master',
1502-
uri: 'https://github.com/sclorg/nodejs-ex'
1503-
},
1504-
type: 'Git'
1505-
}
1506-
}
1507-
})
1508-
};
1509-
const pvcResult = {
1510-
error: null,
1511-
stderr: '',
1512-
stdout: JSON.stringify({
1513-
metadata: {
1514-
labels: {
1515-
app: 'app',
1516-
'app.kubernetes.io/instance': 'comp4',
1517-
'app.kubernetes.io/part-of': 'app',
1518-
'app.kubernetes.io/storage-name': 'storage1'
1519-
}
1520-
},
1521-
spec: {
1522-
resources: {
1523-
requests: {
1524-
storage: '1Gi'
1525-
}
1526-
}
1527-
}
1528-
})
1529-
};
1530-
const routeResult = {
1531-
error: null,
1532-
stderr: '',
1533-
stdout: JSON.stringify({
1534-
apiVersion: 'v1',
1535-
items: [
1536-
{
1537-
apiVersion: 'route.openshift.io/v1',
1538-
kind: 'Route',
1539-
metadata: {
1540-
labels: {
1541-
'app.kubernetes.io/instance': 'comp4',
1542-
'app.kubernetes.io/part-of': 'app',
1543-
'odo.openshift.io/url-name': 'url1'
1544-
}
1545-
},
1546-
spec: {
1547-
port: {
1548-
targetPort: 8080
1549-
}
1550-
}
1551-
}
1552-
],
1553-
kind: 'List',
1554-
metadata: {
1555-
resourceVersion: '',
1556-
selfLink: ''
1557-
}
1558-
})
1559-
};
1560-
setup(() => {
1561-
quickPickStub = sandbox.stub(vscode.window, 'showQuickPick');
1562-
quickPickStub.onFirstCall().resolves(AddWorkspaceFolder);
1563-
execStub.onFirstCall().resolves(componentResult);
1564-
execStub.onSecondCall().resolves(bcResult);
1565-
execStub.onCall(3).resolves(pvcResult);
1566-
execStub.onCall(5).resolves(routeResult);
1567-
sandbox.stub(vscode.window, 'showOpenDialog').resolves([vscode.Uri.parse('file:///c%3A/Temp')]);
1568-
});
1569-
1570-
test('returns null when no work space folder selected', async () => {
1571-
quickPickStub.onFirstCall().resolves(undefined);
1572-
const result = await Component.import(componentItem);
1573-
expect(result).null;
1574-
});
1575-
1576-
test('returns if binary Openshift Component is not supported', async () => {
1577-
execStub.onFirstCall().resolves({
1578-
error: null,
1579-
stderr: '',
1580-
stdout: JSON.stringify({
1581-
items: [
1582-
{
1583-
metadata: {
1584-
annotations: {
1585-
'app.kubernetes.io/component-source-type': 'binary',
1586-
'app.openshift.io/vcs-uri': 'https://github.com/sclorg/nodejs-ex'
1587-
}
1588-
}
1589-
}
1590-
]
1591-
})
1592-
});
1593-
const result = await Component.import(componentItem);
1594-
expect(result).equals('Import for binary OpenShift Components is not supported.');
1595-
});
1596-
1597-
test('throw error when component type is unknown', async () => {
1598-
let expectedError: Error;
1599-
execStub.onFirstCall().resolves({
1600-
error: null,
1601-
stderr: '',
1602-
stdout: JSON.stringify({
1603-
items: [
1604-
{
1605-
metadata: {
1606-
annotations: {
1607-
'app.kubernetes.io/component-source-type': 'mock',
1608-
'app.openshift.io/vcs-uri': 'https://github.com/sclorg/nodejs-ex'
1609-
}
1610-
}
1611-
}
1612-
]
1613-
})
1614-
});
1615-
try {
1616-
await Component.import(componentItem);
1617-
} catch (error) {
1618-
expectedError = error;
1619-
}
1620-
expect(expectedError.message).equals('Cannot import unknown Component type \'mock\'.');
1621-
});
1622-
1623-
test('throw error when import failed', async () => {
1624-
let expectedError: Error;
1625-
const err = '';
1626-
execStub.onSecondCall().rejects(err);
1627-
try {
1628-
await Component.import(componentItem);
1629-
} catch (error) {
1630-
expectedError = error;
1631-
}
1632-
expect(expectedError.message).equals(`Component import failed with error '${err}'.`);
1633-
});
1634-
1635-
test('Successfully imported for git component', async () => {
1636-
const gitUrl = 'https://github.com/sclorg/nodejs-ex';
1637-
const gitRef = 'master';
1638-
const componentType = 'nodejs';
1639-
const version = 'latest';
1640-
const result = await Component.import(componentItem);
1641-
expect(execStub).calledWith(Command.createGitComponent(projectItem.getName(), appItem.getName(), componentType, version, componentItem.getName(), gitUrl, gitRef));
1642-
expect(result).equals(`Component '${componentItem.getName()}' was successfully imported.`);
1643-
1644-
});
1645-
});
1646-
16471439
suite('debug', () => {
16481440
test('without context exits if no component selected', async () => {
16491441
sandbox.stub(OpenShiftItem, 'getOpenShiftCmdData').resolves(null);

0 commit comments

Comments
 (0)