mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 17:23:42 -05:00
Add static logger class for azdata extension (#11939)
* Add static logger class for arc extension * Fix compile errors * Fix test
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as should from 'should';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { HttpClient } from '../../common/httpClient';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
@@ -16,12 +14,6 @@ import { Deferred } from '../../common/promise';
|
||||
|
||||
describe('HttpClient', function (): void {
|
||||
|
||||
let outputChannelMock: TypeMoq.IMock<vscode.OutputChannel>;
|
||||
|
||||
before(function (): void {
|
||||
outputChannelMock = TypeMoq.Mock.ofType<vscode.OutputChannel>();
|
||||
});
|
||||
|
||||
afterEach(function (): void {
|
||||
nock.cleanAll();
|
||||
nock.enableNetConnect();
|
||||
@@ -33,7 +25,7 @@ describe('HttpClient', function (): void {
|
||||
.get('/README.md')
|
||||
.replyWithFile(200, __filename);
|
||||
const downloadFolder = os.tmpdir();
|
||||
const downloadPath = await HttpClient.download('https://127.0.0.1/README.md', downloadFolder, outputChannelMock.object);
|
||||
const downloadPath = await HttpClient.download('https://127.0.0.1/README.md', downloadFolder);
|
||||
// Verify file was downloaded correctly
|
||||
await fs.promises.stat(downloadPath);
|
||||
});
|
||||
@@ -43,7 +35,7 @@ describe('HttpClient', function (): void {
|
||||
nock('https://127.0.0.1')
|
||||
.get('/')
|
||||
.replyWithError('Unexpected Error');
|
||||
const downloadPromise = HttpClient.download('https://127.0.0.1', downloadFolder, outputChannelMock.object);
|
||||
const downloadPromise = HttpClient.download('https://127.0.0.1', downloadFolder);
|
||||
|
||||
await should(downloadPromise).be.rejected();
|
||||
});
|
||||
@@ -53,7 +45,7 @@ describe('HttpClient', function (): void {
|
||||
nock('https://127.0.0.1')
|
||||
.get('/')
|
||||
.reply(404, '');
|
||||
const downloadPromise = HttpClient.download('https://127.0.0.1', downloadFolder, outputChannelMock.object);
|
||||
const downloadPromise = HttpClient.download('https://127.0.0.1', downloadFolder);
|
||||
|
||||
await should(downloadPromise).be.rejected();
|
||||
});
|
||||
@@ -69,7 +61,7 @@ describe('HttpClient', function (): void {
|
||||
nock('https://127.0.0.1')
|
||||
.get('/')
|
||||
.reply(200, '');
|
||||
const downloadPromise = HttpClient.download('https://127.0.0.1', downloadFolder, outputChannelMock.object);
|
||||
const downloadPromise = HttpClient.download('https://127.0.0.1', downloadFolder);
|
||||
// Wait for the stream to be created before throwing the error or HttpClient will miss the event
|
||||
await deferredPromise;
|
||||
try {
|
||||
@@ -87,7 +79,7 @@ describe('HttpClient', function (): void {
|
||||
nock('https://127.0.0.1')
|
||||
.get(`/${filename}`)
|
||||
.reply(200);
|
||||
const receivedFilename = await HttpClient.getFilename(`https://127.0.0.1/${filename}`, outputChannelMock.object);
|
||||
const receivedFilename = await HttpClient.getFilename(`https://127.0.0.1/${filename}`);
|
||||
|
||||
should(receivedFilename).equal(filename);
|
||||
});
|
||||
@@ -96,7 +88,7 @@ describe('HttpClient', function (): void {
|
||||
nock('https://127.0.0.1')
|
||||
.get('/')
|
||||
.replyWithError('Unexpected Error');
|
||||
const getFilenamePromise = HttpClient.getFilename('https://127.0.0.1', outputChannelMock.object);
|
||||
const getFilenamePromise = HttpClient.getFilename('https://127.0.0.1');
|
||||
|
||||
await should(getFilenamePromise).be.rejected();
|
||||
});
|
||||
@@ -105,7 +97,7 @@ describe('HttpClient', function (): void {
|
||||
nock('https://127.0.0.1')
|
||||
.get('/')
|
||||
.reply(404, '');
|
||||
const getFilenamePromise = HttpClient.getFilename('https://127.0.0.1', outputChannelMock.object);
|
||||
const getFilenamePromise = HttpClient.getFilename('https://127.0.0.1');
|
||||
|
||||
await should(getFilenamePromise).be.rejected();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user