Skip to content

Commit 25f0e3c

Browse files
committed
Add separate tests for valid/invalid pack install
1 parent e19adde commit 25f0e3c

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

extensions/ql-vscode/src/packaging.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export async function handleInstallPacks(
123123
if (failedPacks.length > 0) {
124124
void logger.log(`Errors:\n${errors.join('\n')}`);
125125
throw new Error(
126-
`Unable to install packs: ${failedPacks.join(', ')}. See logs for more details.`
126+
`Unable to install packs: ${failedPacks.join(', ')}. See log for more details.`
127127
);
128128
} else {
129129
void showAndLogInformationMessage('Finished installing packs.');
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: foo/bar
2+
version: 0.0.0
3+
dependencies:
4+
foo/baz: '*'

extensions/ql-vscode/src/vscode-tests/cli-integration/packaging.test.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('Packaging commands', function() {
7777
);
7878
});
7979

80-
it('should show error for invalid user-specified pack', async () => {
80+
it('should show error when downloading invalid user-specified pack', async () => {
8181
quickPickSpy.resolves('Download custom specified pack');
8282
inputBoxSpy.resolves('foo/not-a-real-pack@0.0.1');
8383

@@ -88,7 +88,7 @@ describe('Packaging commands', function() {
8888
);
8989
});
9090

91-
it('should attempt to install selected workspace packs', async () => {
91+
it('should install valid workspace pack', async () => {
9292
const rootDir = path.join(__dirname, '../../../src/vscode-tests/cli-integration/data');
9393
quickPickSpy.resolves([
9494
{
@@ -97,11 +97,26 @@ describe('Packaging commands', function() {
9797
},
9898
]);
9999

100+
await mod.handleInstallPacks(cli, progress);
101+
expect(showAndLogInformationMessageSpy.firstCall.args[0]).to.contain(
102+
'Finished installing packs.'
103+
);
104+
});
105+
106+
it('should throw an error when installing invalid workspace pack', async () => {
107+
const rootDir = path.join(__dirname, '../../../src/vscode-tests/cli-integration/data-invalid-pack');
108+
quickPickSpy.resolves([
109+
{
110+
label: 'foo/bar',
111+
packRootDir: [rootDir],
112+
},
113+
]);
114+
100115
try {
116+
// expect this to throw an error
101117
await mod.handleInstallPacks(cli, progress);
102-
expect(showAndLogInformationMessageSpy.firstCall.args[0]).to.contain(
103-
'Finished installing packs.'
104-
);
118+
// This line should not be reached
119+
expect(true).to.be.false;
105120
} catch (error) {
106121
expect(error.message).to.contain('Unable to install packs:');
107122
}

0 commit comments

Comments
 (0)