@@ -8,16 +8,16 @@ import * as path from 'path';
88import * as chai from 'chai' ;
99import * as util from '../../../src/common' ;
1010import { CreateTmpDir , TmpAsset } from '../../../src/CreateTmpAsset' ;
11- import { InstallZip } from '../../../src/packageManager/ZipInstaller ' ;
11+ import { InstallArchive } from '../../../src/packageManager/ArchiveInstaller ' ;
1212import { EventStream } from '../../../src/EventStream' ;
1313import { PlatformInformation } from '../../../src/platform' ;
14- import { BaseEvent , InstallationStart } from '../../../src/omnisharp/loggingEvents' ;
14+ import { BaseEvent , InstallationStart , ArchiveError } from '../../../src/omnisharp/loggingEvents' ;
1515import { Files , Binaries , createTestZipAsync } from '../testAssets/CreateTestZip' ;
1616
1717chai . use ( require ( "chai-as-promised" ) ) ;
1818let expect = chai . expect ;
1919
20- suite ( 'ZipInstaller ' , ( ) => {
20+ suite ( 'ArchiveInstaller ' , ( ) => {
2121 let tmpInstallDir : TmpAsset ;
2222 let installationPath : string ;
2323 let testBuffer : Buffer ;
@@ -38,15 +38,15 @@ suite('ZipInstaller', () => {
3838 } ) ;
3939
4040 test ( 'The folder is unzipped and all the files are present at the expected paths' , async ( ) => {
41- await InstallZip ( testBuffer , fileDescription , installationPath , [ ] , eventStream ) ;
41+ await InstallArchive ( testBuffer , fileDescription , installationPath , [ ] , eventStream ) ;
4242 for ( let elem of allFiles ) {
4343 let filePath = path . join ( installationPath , elem . path ) ;
4444 expect ( await util . fileExists ( filePath ) ) . to . be . true ;
4545 }
4646 } ) ;
4747
4848 test ( 'The folder is unzipped and all the expected events are created' , async ( ) => {
49- await InstallZip ( testBuffer , fileDescription , installationPath , [ ] , eventStream ) ;
49+ await InstallArchive ( testBuffer , fileDescription , installationPath , [ ] , eventStream ) ;
5050 let eventSequence : BaseEvent [ ] = [
5151 new InstallationStart ( fileDescription )
5252 ] ;
@@ -56,7 +56,7 @@ suite('ZipInstaller', () => {
5656 test ( 'The folder is unzipped and the binaries have the expected permissions(except on Windows)' , async ( ) => {
5757 if ( ! ( ( await PlatformInformation . GetCurrent ( ) ) . isWindows ( ) ) ) {
5858 let resolvedBinaryPaths = Binaries . map ( binary => path . join ( installationPath , binary . path ) ) ;
59- await InstallZip ( testBuffer , fileDescription , installationPath , resolvedBinaryPaths , eventStream ) ;
59+ await InstallArchive ( testBuffer , fileDescription , installationPath , resolvedBinaryPaths , eventStream ) ;
6060 for ( let binaryPath of resolvedBinaryPaths ) {
6161 expect ( await util . fileExists ( binaryPath ) ) . to . be . true ;
6262 let mode = ( await fs . stat ( binaryPath ) ) . mode ;
@@ -65,8 +65,21 @@ suite('ZipInstaller', () => {
6565 }
6666 } ) ;
6767
68- test ( 'Error is thrown when the file is not a zip' , async ( ) => {
69- expect ( InstallZip ( new Buffer ( "My file" , "utf8" ) , "Text File" , installationPath , [ ] , eventStream ) ) . to . be . rejected ;
68+ test ( 'Error is thrown when the buffer contains an invalid archive' , async ( ) => {
69+ expect ( InstallArchive ( new Buffer ( "My file" , "utf8" ) , "Text File" , installationPath , [ ] , eventStream ) ) . to . be . rejected ;
70+ } ) ;
71+
72+ test ( 'Error event is created when the buffer contains an invalid archive' , async ( ) => {
73+ try {
74+ await InstallArchive ( new Buffer ( "some content" , "utf8" ) , "Text File" , installationPath , [ ] , eventStream ) ;
75+ }
76+ catch {
77+ let eventSequence : BaseEvent [ ] = [
78+ new InstallationStart ( "Text File" ) ,
79+ new ArchiveError ( "C# Extension was unable to download its dependencies. Please check your internet connection. If you use a proxy server, please visit https://aka.ms/VsCodeCsharpNetworking" )
80+ ] ;
81+ expect ( eventBus ) . to . be . deep . equal ( eventSequence ) ;
82+ }
7083 } ) ;
7184
7285 teardown ( async ( ) => {
0 commit comments