Skip to content

Commit 5d12d46

Browse files
authored
Remove unused method getProjectNames() (#2014)
Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 1475f73 commit 5d12d46

File tree

9 files changed

+1
-42
lines changed

9 files changed

+1
-42
lines changed

src/openshift/openshiftItem.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ export default class OpenShiftItem {
8989
return (tokenRegex) ? tokenRegex[1] : null;
9090
}
9191

92-
static async getProjectNames(): Promise<OpenShiftObject[]> {
93-
const projectList: Array<OpenShiftObject> = await OpenShiftItem.odo.getProjects();
94-
if (projectList.length === 0) throw new VsCommandError(errorMessage.Project);
95-
return projectList;
96-
}
97-
9892
static async getApplicationNames(project: OpenShiftObject, createCommand = false): Promise<Array<OpenShiftObject | QuickPickCommand>> {
9993
return OpenShiftItem.odo.getApplications(project).then((applicationList) => {
10094
if (applicationList.length === 0 && !createCommand) throw new VsCommandError(errorMessage.Component);

test/unit/openshift/application.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ suite('OpenShift/Application', () => {
2020
let quickPickStub: sinon.SinonStub;
2121
let sandbox: sinon.SinonSandbox;
2222
let execStub: sinon.SinonStub;
23-
let getProjectNamesStub: sinon.SinonStub;
2423
const projectItem = new TestItem(null, 'project', ContextType.PROJECT);
2524
const appItem = new TestItem(projectItem, 'app', ContextType.APPLICATION);
2625
const compItem = new TestItem(appItem, 'app', ContextType.COMPONENT_NO_CONTEXT, [], null);
@@ -31,7 +30,6 @@ suite('OpenShift/Application', () => {
3130
sandbox = sinon.createSandbox();
3231
execStub = sandbox.stub(OdoImpl.prototype, 'execute').resolves({error: null, stdout: '', stderr: ''});
3332
sandbox.stub(OdoImpl.prototype, 'getApplications').resolves([appItem]);
34-
getProjectNamesStub = sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
3533
sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
3634
sandbox.stub(vscode.window, 'showInputBox');
3735
});
@@ -59,7 +57,6 @@ suite('OpenShift/Application', () => {
5957
suite('called from command palette', () => {
6058

6159
test('calls the appropriate error message when no project found', async () => {
62-
getProjectNamesStub.restore();
6360
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([]);
6461
try {
6562
await Application.describe(null);

test/unit/openshift/cluster.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ suite('Openshift/Cluster', () => {
6464
infoStub = sandbox.stub(vscode.window, 'showInformationMessage').resolves('Yes');
6565
quickPickStub = sandbox.stub(vscode.window, 'showQuickPick').resolves({label: 'Credentials', description: 'Log in to the given server using credentials'});
6666
loginStub = sandbox.stub(OdoImpl.prototype, 'requireLogin').resolves(true);
67-
sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
6867
sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
6968
});
7069

@@ -236,7 +235,7 @@ suite('Openshift/Cluster', () => {
236235

237236
suite('token', () => {
238237
setup(() => {
239-
sandbox.stub(vscode.env.clipboard, 'readText').resolves('oc login https://162.165.64.43:8443 --token=bX6eP0d4IRgXwWuCKq2856h5fyK9c2U5tOKCwFeEmQA');
238+
sandbox.stub(Cluster, 'readFromClipboard').resolves('oc login https://162.165.64.43:8443 --token=bX6eP0d4IRgXwWuCKq2856h5fyK9c2U5tOKCwFeEmQA');
240239
quickPickStub.resolves({label: 'Token', description: 'Log in to the given server using bearer token'});
241240
inputStub.resolves('token');
242241
});

test/unit/openshift/component.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ suite('OpenShift/Component', () => {
6666
sandbox.stub(OdoImpl.prototype, 'getApplications').resolves([]);
6767
getComponentsStub = sandbox.stub(OdoImpl.prototype, 'getComponents').resolves([]);
6868
sandbox.stub(Util, 'wait').resolves();
69-
sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
7069
getApps = sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
7170
sandbox.stub(OpenShiftItem, 'getComponentNames').resolves([componentItem]);
7271
sandbox.stub(OpenShiftItem, 'getServiceNames').resolves([serviceItem]);

test/unit/openshift/openshiftitem.test.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,6 @@ suite('OpenShiftItem', () => {
3737
return wait();
3838
});
3939

40-
suite('getProjectNames', ()=> {
41-
42-
test('returns an array of application names for the project if there is at least one project', async ()=> {
43-
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([projectItem]);
44-
const appNames = await OpenShiftItem.getProjectNames();
45-
expect(appNames[0].getName()).equals('project');
46-
47-
});
48-
49-
test('throws error if there are no projects available', async ()=> {
50-
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([]);
51-
try {
52-
await OpenShiftItem.getProjectNames();
53-
} catch (err) {
54-
expect(err.message).equals('You need at least one Project available. Please create new OpenShift Project and try again.');
55-
return;
56-
}
57-
fail('should throw error in case projects array is empty');
58-
});
59-
});
60-
6140
suite('validateMatches', ()=> {
6241

6342
test('returns validation message if provided value is not in lower case alphanumeric characters or "-"', ()=> {

test/unit/openshift/project.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ suite('OpenShift/Project', () => {
3333
sandbox.stub(OdoImpl.prototype, 'getClusters').resolves([cluster]);
3434
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([projectItem]);
3535
execStub = sandbox.stub(OdoImpl.prototype, 'execute').resolves({error: undefined, stdout: '', stderr: ''});
36-
sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
3736
sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
3837
});
3938

test/unit/openshift/service.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ suite('OpenShift/Service', () => {
3939
getServicesStub = sandbox.stub(OdoImpl.prototype, 'getServices').resolves([serviceItem]);
4040
termStub = sandbox.stub(OdoImpl.prototype, 'executeInTerminal');
4141
quickPickStub = sandbox.stub(vscode.window, 'showQuickPick');
42-
sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
4342
sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
4443
sandbox.stub(OpenShiftItem, 'getServiceNames').resolves([serviceItem]);
4544
execStub = sandbox.stub(OdoImpl.prototype, 'execute').resolves({ stdout: '' });

test/unit/openshift/storage.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ suite('OpenShift/Storage', () => {
2121
let execStub: sinon.SinonStub;
2222
let quickPickStub: sinon.SinonStub;
2323
let inputStub: sinon.SinonStub;
24-
let getProjectNamesStub: sinon.SinonStub;
2524
let getProjectsStub: sinon.SinonStub;
2625
let getStorageNamesStub: sinon.SinonStub;
2726
const projectItem = new TestItem(null, 'project', ContextType.PROJECT);
@@ -49,7 +48,6 @@ suite('OpenShift/Storage', () => {
4948
getProjectsStub = sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([projectItem]);
5049
quickPickStub.onFirstCall().resolves(appItem);
5150
quickPickStub.onSecondCall().resolves(componentItem);
52-
getProjectNamesStub = sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
5351
sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
5452
sandbox.stub(OdoImpl.prototype, 'getApplicationChildren').resolves([componentItem]);
5553
inputStub = sandbox.stub(vscode.window, 'showInputBox');
@@ -64,7 +62,6 @@ suite('OpenShift/Storage', () => {
6462

6563
test('calls the appropriate error message if no project found', async () => {
6664
quickPickStub.restore();
67-
getProjectNamesStub.restore();
6865
getProjectsStub.restore();
6966
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([]);
7067
sandbox.stub(vscode.window, 'showErrorMessage');
@@ -286,7 +283,6 @@ suite('OpenShift/Storage', () => {
286283
let warnStub: sinon.SinonStub;
287284

288285
setup(() => {
289-
getProjectNamesStub = sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
290286
sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
291287
sandbox.stub(OpenShiftItem, 'getStorageNames').resolves([storageItem]);
292288
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([projectItem]);

test/unit/openshift/url.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ suite('OpenShift/URL', () => {
2424
let inputStub: sinon.SinonStub;
2525
let termStub: sinon.SinonStub;
2626
let execStub: sinon.SinonStub;
27-
let getProjectsNameStub: sinon.SinonStub;
2827
let getApplicationNamesStub: sinon.SinonStub;
2928
let getComponentsNameStub: sinon.SinonStub;
3029
let getRouteNameStub: sinon.SinonStub;
@@ -181,7 +180,6 @@ suite('OpenShift/URL', () => {
181180
sandbox = sinon.createSandbox();
182181
quickPickStub = sandbox.stub(vscode.window, 'showQuickPick');
183182
inputStub = sandbox.stub(vscode.window, 'showInputBox');
184-
getProjectsNameStub = sandbox.stub(OpenShiftItem, 'getProjectNames').resolves([projectItem]);
185183
getRouteNameStub = sandbox.stub(OpenShiftItem, 'getRoutes').resolves([routeItem]);
186184
getApplicationNamesStub = sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
187185
getComponentsNameStub = sandbox.stub(OpenShiftItem, 'getComponentNames').resolves([componentItem]);
@@ -206,7 +204,6 @@ suite('OpenShift/URL', () => {
206204

207205
test('calls the appropriate error message if no project found', async () => {
208206
quickPickStub.restore();
209-
getProjectsNameStub.restore();
210207
getProjectsStub.restore();
211208
sandbox.stub(OdoImpl.prototype, 'getProjects').resolves([]);
212209
sandbox.stub(vscode.window, 'showErrorMessage');

0 commit comments

Comments
 (0)