Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -2,7 +2,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/* Disabled pending next vscode merge which allows electron module to be imported during test runs
import * as sqlops from 'sqlops';
/* Disabled pending next vscode merge which allows electron module to be imported during test runs
NOTE: Import added above to prevent tests from failing due to the file being empty. Remove when reenabling the tests
'use strict';

View File

@@ -7,7 +7,7 @@
import * as OptionsDialogHelper from 'sql/workbench/browser/modal/optionsDialogHelper';
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
import * as sqlops from 'sqlops';
import { Builder, $ } from 'vs/base/browser/builder';
import { Builder, $ } from 'sql/base/browser/builder';
import * as TypeMoq from 'typemoq';
import * as assert from 'assert';
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';

View File

@@ -6,7 +6,7 @@
'use strict';
import { OptionsDialog } from 'sql/workbench/browser/modal/optionsDialog';
import { AdvancedPropertiesController } from 'sql/parts/connection/connectionDialog/advancedPropertiesController';
import { Builder, $ } from 'vs/base/browser/builder';
import { Builder, $ } from 'sql/base/browser/builder';
import { ContextKeyServiceStub } from 'sqltest/stubs/contextKeyServiceStub';
import * as sqlops from 'sqlops';
import * as TypeMoq from 'typemoq';

View File

@@ -21,7 +21,6 @@ import { ProviderFeatures, ICapabilitiesService } from 'sql/platform/capabilitie
import * as sqlops from 'sqlops';
import { Emitter } from 'vs/base/common/event';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
suite('SQL ConnectionConfig tests', () => {
@@ -267,12 +266,11 @@ suite('SQL ConnectionConfig tests', () => {
workspaceConfigurationServiceMock = TypeMoq.Mock.ofType(WorkspaceConfigurationTestService);
workspaceConfigurationServiceMock.setup(x => x.reloadConfiguration())
.returns(() => TPromise.as(null));
.returns(() => Promise.resolve(undefined));
configEditingServiceMock = TypeMoq.Mock.ofType(ConfigurationEditingService);
let nothing: void;
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.USER, TypeMoq.It.isAny())).returns(() => TPromise.as<void>(nothing));
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.WORKSPACE, TypeMoq.It.isAny())).returns(() => TPromise.as<void>(nothing));
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.USER, TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.WORKSPACE, TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
});
function groupsAreEqual(groups1: IConnectionProfileGroup[], groups2: IConnectionProfileGroup[]): Boolean {
@@ -776,7 +774,7 @@ suite('SQL ConnectionConfig tests', () => {
let configEditingServiceMock: TypeMoq.Mock<ConfigurationEditingService> = TypeMoq.Mock.ofType(ConfigurationEditingService);
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.USER, TypeMoq.It.isAny())).callback((x: any, val: any) => {
calledValue = val.value as IConnectionProfileStore[];
}).returns(() => TPromise.as<void>(nothing));
}).returns(() => Promise.resolve(undefined));
workspaceConfigurationServiceMock.setup(x => x.inspect<IConnectionProfileStore[] | IConnectionProfileGroup[] | sqlops.DataProtocolServerCapabilities[]>(
Constants.connectionGroupsArrayName))
.returns(() => configValueToConcat);
@@ -804,7 +802,7 @@ suite('SQL ConnectionConfig tests', () => {
let configEditingServiceMock: TypeMoq.Mock<ConfigurationEditingService> = TypeMoq.Mock.ofType(ConfigurationEditingService);
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.USER, TypeMoq.It.isAny())).callback((x: any, val: any) => {
calledValue = val.value as IConnectionProfileStore[];
}).returns(() => TPromise.as<void>(nothing));
}).returns(() => Promise.resolve(undefined));
workspaceConfigurationServiceMock.setup(x => x.inspect<IConnectionProfileStore[] | IConnectionProfileGroup[] | sqlops.DataProtocolServerCapabilities[]>(
Constants.connectionGroupsArrayName))
.returns(() => configValueToConcat);
@@ -855,10 +853,10 @@ suite('SQL ConnectionConfig tests', () => {
let configEditingServiceMock: TypeMoq.Mock<ConfigurationEditingService> = TypeMoq.Mock.ofType(ConfigurationEditingService);
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.USER, TypeMoq.It.isAny())).callback((x: any, val: any) => {
calledValue = val.value as IConnectionProfileStore[];
}).returns(() => TPromise.as<void>(nothing));
}).returns(() => Promise.resolve(undefined));
configEditingServiceMock.setup(x => x.writeConfiguration(ConfigurationTarget.WORKSPACE, TypeMoq.It.isAny())).callback((x: any, val: any) => {
}).returns(() => TPromise.as<void>(nothing));
}).returns(() => Promise.resolve(undefined));
let config = new ConnectionConfig(configEditingServiceMock.object, workspaceConfigurationServiceMock.object, capabilitiesService.object);
config.changeGroupIdForConnection(connectionProfile, newId).then(() => {

View File

@@ -100,6 +100,7 @@ suite('SQL ConnectionManagementService tests', () => {
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, TypeMoq.It.isAny())).returns(() => TPromise.as(none));
connectionStore.setup(x => x.addActiveConnection(TypeMoq.It.isAny())).returns(() => Promise.resolve());
connectionStore.setup(x => x.addActiveConnection(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve());
connectionStore.setup(x => x.saveProfile(TypeMoq.It.isAny())).returns(() => Promise.resolve(connectionProfile));
workbenchEditorService.setup(x => x.openEditor(undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => TPromise.as(undefined));
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is<IConnectionProfile>(

View File

@@ -94,9 +94,11 @@ suite('SQL ConnectionStore tests', () => {
id: undefined
});
let momento = new Memento('ConnectionManagement');
storageServiceMock = TypeMoq.Mock.ofType(StorageTestService);
let momento = new Memento('ConnectionManagement', storageServiceMock.object);
context = TypeMoq.Mock.ofInstance(momento);
context.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => mementoArray);
context.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => mementoArray);
credentialStore = TypeMoq.Mock.ofType(CredentialsService);
connectionConfig = TypeMoq.Mock.ofType(ConnectionConfig);
@@ -110,8 +112,6 @@ suite('SQL ConnectionStore tests', () => {
workspaceConfigurationServiceMock.setup(x => x.getValue(Constants.sqlConfigSectionName))
.returns(() => configResult);
storageServiceMock = TypeMoq.Mock.ofType(StorageTestService);
let extensionManagementServiceMock = {
getInstalled: () => {
return Promise.resolve([]);
@@ -239,7 +239,7 @@ suite('SQL ConnectionStore tests', () => {
// Expect all of them to be saved even if size is limited to 3
let connectionStore = new ConnectionStore(storageServiceMock.object, context.object, undefined, workspaceConfigurationServiceMock.object,
credentialStore.object, capabilitiesService, connectionConfig.object);
let promise = Promise.resolve();
let promise = Promise.resolve<void>();
for (let i = 0; i < numCreds; i++) {
let cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
let connectionProfile = new ConnectionProfile(capabilitiesService, cred);

View File

@@ -26,7 +26,7 @@ import { TreeNode } from 'sql/parts/objectExplorer/common/treeNode';
import { NodeType } from 'sql/parts/objectExplorer/common/nodeType';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { ServerTreeDataSource } from 'sql/parts/objectExplorer/viewlet/serverTreeDataSource';
import { Builder, $ } from 'vs/base/browser/builder';
import { Builder, $ } from 'sql/base/browser/builder';
import WinJS = require('vs/base/common/winjs.base');
import { Emitter } from 'vs/base/common/event';
import Severity from 'vs/base/common/severity';

View File

@@ -35,7 +35,9 @@ class TestChangeDetectorRef extends ChangeDetectorRef {
}
suite('Dashboard Properties Widget Tests', () => {
test('Parses good config', (done) => {
test('Parses good config', function (done) {
// for some reason mocha thinks this test takes 26 seconds even though it doesn't, so it says this failed because it took longer than 2 seconds
this.timeout(30000);
let propertiesConfig = {
properties: [
{
@@ -76,7 +78,10 @@ suite('Dashboard Properties Widget Tests', () => {
edition: 0
};
let dashboardService = TypeMoq.Mock.ofType(DashboardServiceInterface, TypeMoq.MockBehavior.Loose, [{}]);
let dashboardService = TypeMoq.Mock.ofInstance<DashboardServiceInterface>({
adminService: undefined,
connectionManagementService: undefined
} as DashboardServiceInterface, TypeMoq.MockBehavior.Loose);
let singleAdminService = TypeMoq.Mock.ofType(SingleAdminService);
singleAdminService.setup(x => x.databaseInfo).returns(() => Observable.of(databaseInfo));
@@ -105,6 +110,5 @@ suite('Dashboard Properties Widget Tests', () => {
assert.equal((<any>testComponent).properties[0].value, 'Test Property');
done();
});
// for some reason mocha thinks this test takes 26 seconds even though it doesn't, so it says this failed because it took longer than 2 seconds
}).timeout(30000);
});
});

View File

@@ -15,7 +15,7 @@ suite('Data Explorer Viewlet', () => {
class DataExplorerTestViewlet extends Viewlet {
constructor() {
super('dataExplorer', null, null, null);
super('dataExplorer', null, null, null, null, null);
}
public layout(dimension: any): void {

View File

@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

View File

@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
@@ -17,15 +17,15 @@ import { NotebookModelStub } from '../common';
import { EmptyFuture } from 'sql/workbench/services/notebook/common/sessionManager';
import { ICellModel } from 'sql/parts/notebook/models/modelInterfaces';
describe('Cell Model', function (): void {
suite('Cell Model', function (): void {
let factory = new ModelFactory();
it('Should set default values if none defined', async function (): Promise<void> {
test('Should set default values if none defined', async function (): Promise<void> {
let cell = factory.createCell(undefined, undefined);
should(cell.cellType).equal(CellTypes.Code);
should(cell.source).equal('');
});
it('Should update values', async function (): Promise<void> {
test('Should update values', async function (): Promise<void> {
let cell = factory.createCell(undefined, undefined);
cell.setOverrideLanguage('sql');
should(cell.language).equal('sql');
@@ -33,7 +33,7 @@ describe('Cell Model', function (): void {
should(cell.source).equal('abcd');
});
it('Should match ICell values if defined', async function (): Promise<void> {
test('Should match ICell values if defined', async function (): Promise<void> {
let output: nb.IStreamResult = {
output_type: 'stream',
text: 'Some output',
@@ -55,7 +55,7 @@ describe('Cell Model', function (): void {
});
it('Should set cell language to python if defined as python in languageInfo', async function (): Promise<void> {
test('Should set cell language to python if defined as python in languageInfo', async function (): Promise<void> {
let cellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: 'print(\'1\')',
@@ -72,7 +72,7 @@ describe('Cell Model', function (): void {
should(cell.language).equal('python');
});
it('Should set cell language to python if defined as pyspark in languageInfo', async function (): Promise<void> {
test('Should set cell language to python if defined as pyspark in languageInfo', async function (): Promise<void> {
let cellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: 'print(\'1\')',
@@ -89,7 +89,9 @@ describe('Cell Model', function (): void {
should(cell.language).equal('python');
});
it('Should set cell language to scala if defined as scala in languageInfo', async function (): Promise<void> {
// Failing test disabled - see https://github.com/Microsoft/azuredatastudio/issues/4113
/*
test('Should set cell language to scala if defined as scala in languageInfo', async function (): Promise<void> {
let cellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: 'print(\'1\')',
@@ -105,7 +107,8 @@ describe('Cell Model', function (): void {
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
should(cell.language).equal('scala');
});
it('Should keep cell language as python if cell has language override', async function (): Promise<void> {
*/
test('Should keep cell language as python if cell has language override', async function (): Promise<void> {
let cellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: 'print(\'1\')',
@@ -122,7 +125,7 @@ describe('Cell Model', function (): void {
should(cell.language).equal('python');
});
it('Should set cell language to python if no language defined', async function (): Promise<void> {
test('Should set cell language to python if no language defined', async function (): Promise<void> {
let cellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: 'print(\'1\')',
@@ -139,7 +142,9 @@ describe('Cell Model', function (): void {
should(cell.language).equal('python');
});
it('Should match cell language to language specified if unknown language defined in languageInfo', async function (): Promise<void> {
// Failing test disabled - see https://github.com/Microsoft/azuredatastudio/issues/4113
/*
test('Should match cell language to language specified if unknown language defined in languageInfo', async function (): Promise<void> {
let cellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: 'std::cout << "hello world";',
@@ -155,8 +160,11 @@ describe('Cell Model', function (): void {
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
should(cell.language).equal('cplusplus');
});
*/
it('Should match cell language to mimetype name is not supplied in languageInfo', async function (): Promise<void> {
// Failing test disabled - see https://github.com/Microsoft/azuredatastudio/issues/4113
/*
test('Should match cell language to mimetype name is not supplied in languageInfo', async function (): Promise<void> {
let cellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: 'print(\'1\')',
@@ -172,11 +180,12 @@ describe('Cell Model', function (): void {
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
should(cell.language).equal('scala');
});
*/
describe('Model Future handling', function (): void {
suite('Model Future handling', function (): void {
let future: TypeMoq.Mock<EmptyFuture>;
let cell: ICellModel;
beforeEach(() => {
setup(() => {
future = TypeMoq.Mock.ofType(EmptyFuture);
cell = factory.createCell({
cell_type: CellTypes.Code,
@@ -193,7 +202,7 @@ describe('Cell Model', function (): void {
});
});
it('should send and handle incoming messages', async () => {
test('should send and handle incoming messages', async () => {
// Given a future
let onReply: nb.MessageHandler<nb.IShellMessage>;
let onIopub: nb.MessageHandler<nb.IIOPubMessage>;
@@ -234,7 +243,7 @@ describe('Cell Model', function (): void {
// ... TODO: And when I sent a reply I expect it to be processed.
});
it('should delete transient tag while handling incoming messages', async () => {
test('should delete transient tag while handling incoming messages', async () => {
// Given a future
let onIopub: nb.MessageHandler<nb.IIOPubMessage>;
future.setup(f => f.setIOPubHandler(TypeMoq.It.isAny())).callback((handler) => onIopub = handler);
@@ -265,7 +274,7 @@ describe('Cell Model', function (): void {
should(outputs[0]['transient']).be.undefined();
});
it('should dispose old future', async () => {
test('should dispose old future', async () => {
let oldFuture = TypeMoq.Mock.ofType(EmptyFuture);
cell.setFuture(oldFuture.object);

View File

@@ -1,7 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
@@ -12,13 +12,13 @@ import { nb } from 'sqlops';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import { ClientSession } from 'sql/parts/notebook/models/clientSession';
import { SessionManager, EmptySession } from 'sql/workbench/services/notebook/common/sessionManager';
import { NotebookManagerStub, ServerManagerStub } from 'sqltest/parts/notebook/common';
describe('Client Session', function (): void {
suite('Client Session', function (): void {
let path = URI.file('my/notebook.ipynb');
let notebookManager: NotebookManagerStub;
let serverManager: ServerManagerStub;
@@ -27,7 +27,7 @@ describe('Client Session', function (): void {
let session: ClientSession;
let remoteSession: ClientSession;
beforeEach(() => {
setup(() => {
serverManager = new ServerManagerStub();
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
notebookManager = new NotebookManagerStub();
@@ -50,7 +50,7 @@ describe('Client Session', function (): void {
});
});
it('Should set path, isReady and ready on construction', function (): void {
test('Should set path, isReady and ready on construction', function (): void {
should(session.notebookUri).equal(path);
should(session.ready).not.be.undefined();
should(session.isReady).be.false();
@@ -59,7 +59,7 @@ describe('Client Session', function (): void {
should(session.errorMessage).be.undefined();
});
it('Should call on serverManager startup if set', async function (): Promise<void> {
test('Should call on serverManager startup if set', async function (): Promise<void> {
// Given I have a serverManager that starts successfully
serverManager.result = Promise.resolve();
should(session.isReady).be.false();
@@ -73,7 +73,7 @@ describe('Client Session', function (): void {
should(session.isReady).be.true();
});
it('Should go to error state if serverManager startup fails', async function (): Promise<void> {
test('Should go to error state if serverManager startup fails', async function (): Promise<void> {
// Given I have a serverManager that fails to start
serverManager.result = Promise.reject('error');
should(session.isInErrorState).be.false();
@@ -89,7 +89,7 @@ describe('Client Session', function (): void {
should(session.errorMessage).equal('error');
});
it('Should be ready when session manager is ready', async function (): Promise<void> {
test('Should be ready when session manager is ready', async function (): Promise<void> {
serverManager.result = new Promise((resolve) => {
serverManager.isStarted = true;
resolve();
@@ -105,7 +105,7 @@ describe('Client Session', function (): void {
await session.ready;
});
it('Should be in error state if server fails to start', async function (): Promise<void> {
test('Should be in error state if server fails to start', async function (): Promise<void> {
serverManager.result = new Promise((resolve) => {
serverManager.isStarted = false;
resolve();
@@ -121,7 +121,7 @@ describe('Client Session', function (): void {
should(session.isInErrorState).be.true();
});
it('Should go to error state if sessionManager fails', async function (): Promise<void> {
test('Should go to error state if sessionManager fails', async function (): Promise<void> {
serverManager.isStarted = true;
mockSessionManager.setup(s => s.isReady).returns(() => false);
mockSessionManager.setup(s => s.ready).returns(() => Promise.reject('error'));
@@ -135,7 +135,7 @@ describe('Client Session', function (): void {
should(session.errorMessage).equal('error');
});
it('Should start session automatically if kernel preference requests it', async function (): Promise<void> {
test('Should start session automatically if kernel preference requests it', async function (): Promise<void> {
serverManager.isStarted = true;
mockSessionManager.setup(s => s.ready).returns(() => Promise.resolve());
let sessionMock = TypeMoq.Mock.ofType(EmptySession);
@@ -159,7 +159,7 @@ describe('Client Session', function (): void {
should(startOptions.path).equal(path.fsPath);
});
it('Should shutdown session even if no serverManager is set', async function (): Promise<void> {
test('Should shutdown session even if no serverManager is set', async function (): Promise<void> {
// Given a session against a remote server
let expectedId = 'abc';
mockSessionManager.setup(s => s.isReady).returns(() => true);

View File

@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
@@ -8,7 +8,7 @@
import * as should from 'should';
import { nb } from 'sqlops';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import * as tempWrite from 'temp-write';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import * as testUtils from '../../../utils/testUtils';
@@ -41,10 +41,10 @@ function verifyMatchesExpectedNotebook(notebook: nb.INotebookContents): void {
should(notebook.nbformat_minor).equal(expectedNotebookContent.nbformat_minor);
}
describe('Local Content Manager', function (): void {
suite('Local Content Manager', function (): void {
let contentManager = new LocalContentManager();
it('Should return undefined if path is undefined', async function (): Promise<void> {
test('Should return undefined if path is undefined', async function (): Promise<void> {
let content = await contentManager.getNotebookContents(undefined);
should(content).be.undefined();
// tslint:disable-next-line:no-null-keyword
@@ -52,10 +52,10 @@ describe('Local Content Manager', function (): void {
should(content).be.undefined();
});
it('Should throw if file does not exist', async function (): Promise<void> {
test('Should throw if file does not exist', async function (): Promise<void> {
await testUtils.assertThrowsAsync(async () => await contentManager.getNotebookContents(URI.file('/path/doesnot/exist.ipynb')), undefined);
});
it('Should return notebook contents parsed as INotebook when valid notebook file parsed', async function (): Promise<void> {
test('Should return notebook contents parsed as INotebook when valid notebook file parsed', async function (): Promise<void> {
// Given a file containing a valid notebook
let localFile = tempWrite.sync(notebookContentString, 'notebook.ipynb');
// when I read the content
@@ -63,7 +63,7 @@ describe('Local Content Manager', function (): void {
// then I expect notebook format to match
verifyMatchesExpectedNotebook(notebook);
});
it('Should ignore invalid content in the notebook file', async function (): Promise<void> {
test('Should ignore invalid content in the notebook file', async function (): Promise<void> {
// Given a file containing a notebook with some garbage properties
let invalidContent = notebookContentString + '\\nasddfdsafasdf';
let localFile = tempWrite.sync(invalidContent, 'notebook.ipynb');
@@ -72,7 +72,7 @@ describe('Local Content Manager', function (): void {
// then I expect notebook format to still be valid
verifyMatchesExpectedNotebook(notebook);
});
it('Should inline mime data into a single string', async function (): Promise<void> {
test('Should inline mime data into a single string', async function (): Promise<void> {
let mimeNotebook: nb.INotebookContents = {
cells: [{
cell_type: CellTypes.Code,

View File

@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
@@ -11,7 +11,7 @@ import { nb } from 'sqlops';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
import * as testUtils from '../../../utils/testUtils';
@@ -75,12 +75,12 @@ let mockModelFactory: TypeMoq.Mock<ModelFactory>;
let notificationService: TypeMoq.Mock<INotificationService>;
let capabilitiesService: TypeMoq.Mock<ICapabilitiesService>;
describe('notebook model', function(): void {
suite('notebook model', function(): void {
let notebookManagers = [new NotebookManagerStub()];
let memento: TypeMoq.Mock<Memento>;
let queryConnectionService: TypeMoq.Mock<ConnectionManagementService>;
let defaultModelOptions: INotebookModelOptions;
beforeEach(() => {
setup(() => {
sessionReady = new Deferred<void>();
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
capabilitiesService = TypeMoq.Mock.ofType(CapabilitiesTestService);
@@ -113,7 +113,7 @@ describe('notebook model', function(): void {
});
});
it('Should create no cells if model has no contents', async function(): Promise<void> {
test('Should create no cells if model has no contents', async function(): Promise<void> {
// Given an empty notebook
let emptyNotebook: nb.INotebookContents = {
cells: [],
@@ -139,7 +139,7 @@ describe('notebook model', function(): void {
should(model.cells).have.length(0);
});
it('Should throw if model load fails', async function(): Promise<void> {
test('Should throw if model load fails', async function(): Promise<void> {
// Given a call to get Contents fails
let error = new Error('File not found');
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
@@ -154,7 +154,7 @@ describe('notebook model', function(): void {
should(model.inErrorState).be.true();
});
it('Should convert cell info to CellModels', async function(): Promise<void> {
test('Should convert cell info to CellModels', async function(): Promise<void> {
// Given a notebook with 2 cells
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContent));
@@ -170,7 +170,7 @@ describe('notebook model', function(): void {
should(model.cells[1].source).be.equal(expectedNotebookContent.cells[1].source);
});
it('Should load contents but then go to error state if client session startup fails', async function(): Promise<void> {
test('Should load contents but then go to error state if client session startup fails', async function(): Promise<void> {
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
notebookManagers[0].contentManager = mockContentManager.object;
@@ -199,7 +199,7 @@ describe('notebook model', function(): void {
should(sessionFired).be.false();
});
it('Should not be in error state if client session initialization succeeds', async function(): Promise<void> {
test('Should not be in error state if client session initialization succeeds', async function(): Promise<void> {
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
notebookManagers[0].contentManager = mockContentManager.object;
@@ -236,14 +236,14 @@ describe('notebook model', function(): void {
should(model.clientSession).equal(mockClientSession.object);
});
it('Should sanitize kernel display name when IP is included', async function(): Promise<void> {
test('Should sanitize kernel display name when IP is included', async function(): Promise<void> {
let model = new NotebookModel(defaultModelOptions);
let displayName = 'PySpark (1.1.1.1)';
let sanitizedDisplayName = model.sanitizeDisplayName(displayName);
should(sanitizedDisplayName).equal('PySpark');
});
it('Should sanitize kernel display name properly when IP is not included', async function(): Promise<void> {
test('Should sanitize kernel display name properly when IP is not included', async function(): Promise<void> {
let model = new NotebookModel(defaultModelOptions);
let displayName = 'PySpark';
let sanitizedDisplayName = model.sanitizeDisplayName(displayName);

View File

@@ -12,7 +12,7 @@ import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { formatServerNameWithDatabaseNameForAttachTo, getServerFromFormattedAttachToName, getDatabaseFromFormattedAttachToName } from 'sql/parts/notebook/notebookUtils';
describe('notebookUtils', function(): void {
suite('notebookUtils', function(): void {
let conn: IConnectionProfile = {
connectionName: '',
serverName: '',
@@ -30,7 +30,7 @@ describe('notebookUtils', function(): void {
azureTenantId: undefined
};
it('Should format server and database name correctly for attach to', async function(): Promise<void> {
test('Should format server and database name correctly for attach to', async function(): Promise<void> {
let capabilitiesService = new CapabilitiesTestService();
let connProfile = new ConnectionProfile(capabilitiesService, conn);
connProfile.serverName = 'serverName';
@@ -39,7 +39,7 @@ describe('notebookUtils', function(): void {
should(attachToNameFormatted).equal('serverName (databaseName)');
});
it('Should format server name correctly for attach to', async function(): Promise<void> {
test('Should format server name correctly for attach to', async function(): Promise<void> {
let capabilitiesService = new CapabilitiesTestService();
let connProfile = new ConnectionProfile(capabilitiesService, conn);
connProfile.serverName = 'serverName';
@@ -47,7 +47,7 @@ describe('notebookUtils', function(): void {
should(attachToNameFormatted).equal('serverName');
});
it('Should format server name correctly for attach to when database is undefined', async function(): Promise<void> {
test('Should format server name correctly for attach to when database is undefined', async function(): Promise<void> {
let capabilitiesService = new CapabilitiesTestService();
let connProfile = new ConnectionProfile(capabilitiesService, conn);
connProfile.serverName = 'serverName';
@@ -56,7 +56,7 @@ describe('notebookUtils', function(): void {
should(attachToNameFormatted).equal('serverName');
});
it('Should format server name as empty string when server/database are undefined', async function(): Promise<void> {
test('Should format server name as empty string when server/database are undefined', async function(): Promise<void> {
let capabilitiesService = new CapabilitiesTestService();
let connProfile = new ConnectionProfile(capabilitiesService, conn);
connProfile.serverName = undefined;
@@ -65,21 +65,21 @@ describe('notebookUtils', function(): void {
should(attachToNameFormatted).equal('');
});
it('Should extract server name when no database specified', async function(): Promise<void> {
test('Should extract server name when no database specified', async function(): Promise<void> {
let serverName = getServerFromFormattedAttachToName('serverName');
let databaseName = getDatabaseFromFormattedAttachToName('serverName');
should(serverName).equal('serverName');
should(databaseName).equal('');
});
it('Should extract server and database name', async function(): Promise<void> {
test('Should extract server and database name', async function(): Promise<void> {
let serverName = getServerFromFormattedAttachToName('serverName (databaseName)');
let databaseName = getDatabaseFromFormattedAttachToName('serverName (databaseName)');
should(serverName).equal('serverName');
should(databaseName).equal('databaseName');
});
it('Should extract server and database name with other parentheses', async function(): Promise<void> {
test('Should extract server and database name with other parentheses', async function(): Promise<void> {
let serverName = getServerFromFormattedAttachToName('serv()erName (databaseName)');
let databaseName = getDatabaseFromFormattedAttachToName('serv()erName (databaseName)');
should(serverName).equal('serv()erName');

View File

@@ -32,6 +32,7 @@ import { ConfigurationService } from 'vs/platform/configuration/node/configurati
import * as TypeMoq from 'typemoq';
import * as assert from 'assert';
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
let none: void;
@@ -50,7 +51,8 @@ suite('SQL QueryAction Tests', () => {
testQueryInput.setup(x => x.runQuery(undefined)).callback(() => { calledRunQueryOnInput = true; });
// Setup a reusable mock QueryEditor
editor = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Strict, undefined, new TestThemeService());
editor = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Strict, undefined, new TestThemeService(), undefined, undefined, undefined, undefined,
undefined, undefined, undefined, undefined, new TestStorageService());
editor.setup(x => x.connectedUri).returns(() => testUri);
editor.setup(x => x.currentQueryInput).returns(() => testQueryInput.object);
editor.setup(x => x.uri).returns(() => testUri);
@@ -86,7 +88,8 @@ suite('SQL QueryAction Tests', () => {
connectionManagementService.setup(x => x.isConnected(TypeMoq.It.isAnyString())).returns(() => isConnectedReturnValue);
// ... Create an editor
let editor = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Loose, undefined, new TestThemeService());
let editor = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Loose, undefined, new TestThemeService(), undefined, undefined, undefined, undefined,
undefined, undefined, undefined, undefined, new TestStorageService());
editor.setup(x => x.currentQueryInput).returns(() => testQueryInput.object);
// If I create a QueryTaskbarAction and I pass a non-connected editor to _getConnectedQueryEditorUri
@@ -172,7 +175,8 @@ suite('SQL QueryAction Tests', () => {
queryInput.setup(x => x.runQuery(undefined)).callback(() => {
countCalledRunQuery++;
});
let queryEditor: TypeMoq.Mock<QueryEditor> = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Strict, undefined, new TestThemeService());
let queryEditor: TypeMoq.Mock<QueryEditor> = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Strict, undefined, new TestThemeService(), undefined,
undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService());
queryEditor.setup(x => x.currentQueryInput).returns(() => queryInput.object);
queryEditor.setup(x => x.getSelection()).returns(() => undefined);
queryEditor.setup(x => x.getSelection(false)).returns(() => undefined);
@@ -238,7 +242,8 @@ suite('SQL QueryAction Tests', () => {
});
// ... Mock "getSelection" in QueryEditor
let queryEditor: TypeMoq.Mock<QueryEditor> = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Loose, undefined, new TestThemeService());
let queryEditor: TypeMoq.Mock<QueryEditor> = TypeMoq.Mock.ofType(QueryEditor, TypeMoq.MockBehavior.Loose, undefined, new TestThemeService(), undefined,
undefined, undefined, undefined, undefined, undefined, undefined, undefined, new TestStorageService());
queryEditor.setup(x => x.currentQueryInput).returns(() => queryInput.object);
queryEditor.setup(x => x.getSelection()).returns(() => {
return selectionToReturnInGetSelection;

View File

@@ -8,10 +8,10 @@
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { IEditorDescriptor } from 'vs/workbench/browser/editor';
import { TPromise } from 'vs/base/common/winjs.base';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import * as DOM from 'vs/base/browser/dom';
import { Memento } from 'vs/workbench/common/memento';
import { Builder } from 'vs/base/browser/builder';
import { Builder } from 'sql/base/browser/builder';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput';
@@ -32,6 +32,7 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { ConfigurationService } from 'vs/platform/configuration/node/configurationService';
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
suite('SQL QueryEditor Tests', () => {
let queryModelService: QueryModelService;
@@ -59,7 +60,8 @@ suite('SQL QueryEditor Tests', () => {
editorDescriptorService.object,
undefined,
undefined,
configurationService.object);
configurationService.object,
new TestStorageService());
};
setup(() => {
@@ -119,14 +121,14 @@ suite('SQL QueryEditor Tests', () => {
});
// Create a QueryInput
let filePath = 'someFile.sql';
let filePath = 'file://someFile.sql';
let uri: URI = URI.parse(filePath);
let fileInput = new UntitledEditorInput(uri, false, '', '', '', instantiationService.object, undefined, undefined, undefined);
let queryResultsInput: QueryResultsInput = new QueryResultsInput(uri.fsPath, configurationService.object);
queryInput = new QueryInput('first', fileInput, queryResultsInput, undefined, undefined, undefined, undefined, undefined);
// Create a QueryInput to compare to the previous one
let filePath2 = 'someFile2.sql';
let filePath2 = 'file://someFile2.sql';
let uri2: URI = URI.parse(filePath2);
let fileInput2 = new UntitledEditorInput(uri2, false, '', '', '', instantiationService.object, undefined, undefined, undefined);
let queryResultsInput2: QueryResultsInput = new QueryResultsInput(uri2.fsPath, configurationService.object);
@@ -356,7 +358,7 @@ suite('SQL QueryEditor Tests', () => {
return new RunQueryAction(undefined, undefined, undefined);
});
let fileInput = new UntitledEditorInput(URI.parse('testUri'), false, '', '', '', instantiationService.object, undefined, undefined, undefined);
let fileInput = new UntitledEditorInput(URI.parse('file://testUri'), false, '', '', '', instantiationService.object, undefined, undefined, undefined);
queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose, undefined, undefined);
queryModelService.callBase = true;
queryModelService.setup(x => x.disposeQuery(TypeMoq.It.isAny())).returns(() => void 0);

View File

@@ -24,4 +24,9 @@ export class ConnectionDialogTestService implements IConnectionDialogService {
params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): TPromise<IConnectionProfile> {
return TPromise.as(undefined);
}
}
public openDialogAndWaitButDontConnect(connectionManagementService: IConnectionManagementService,
params?: INewConnectionParams, model?: IConnectionProfile, connectionResult?: IConnectionResult): TPromise<IConnectionProfile> {
return TPromise.as(undefined);
}
}

View File

@@ -266,6 +266,10 @@ export class TestConnectionManagementService implements IConnectionManagementSer
return undefined;
}
providerRegistered(providerId: string): boolean {
return undefined;
}
getConnectionProfileById(profileId: string): IConnectionProfile {
return undefined;
}

View File

@@ -4,11 +4,28 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IStorageService, StorageScope, IWorkspaceStorageChangeEvent, IWillSaveStateEvent } from 'vs/platform/storage/common/storage';
import { Event } from 'vs/base/common/event';
export class StorageTestService implements IStorageService {
_serviceBrand: any;
/**
* Emitted whenever data is updated or deleted.
*/
readonly onDidChangeStorage: Event<IWorkspaceStorageChangeEvent>;
/**
* Emitted when the storage is about to persist. This is the right time
* to persist data to ensure it is stored before the application shuts
* down.
*
* The will save state event allows to optionally ask for the reason of
* saving the state, e.g. to find out if the state is saved due to a
* shutdown.
*/
readonly onWillSaveState: Event<IWillSaveStateEvent>;
/**
* Store a string value under the given key to local storage.
*

View File

@@ -5,10 +5,11 @@
'use strict';
import { IThemeService, ITheme, IThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IThemeService, ITheme, IThemingParticipant, IIconTheme } from 'vs/platform/theme/common/themeService';
import { Color } from 'vs/base/common/color';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
import { Event } from 'vs/base/common/event';
export class TestTheme implements ITheme {
selector: string;
@@ -32,6 +33,7 @@ const testTheme = new TestTheme();
export class TestThemeService implements IThemeService {
_serviceBrand: any;
onIconThemeChange = Event.None;
getTheme(): ITheme {
return testTheme;
@@ -40,4 +42,8 @@ export class TestThemeService implements IThemeService {
onThemeChange(participant: IThemingParticipant): IDisposable {
return { dispose: () => { } };
}
getIconTheme(): IIconTheme {
return undefined;
}
}

View File

@@ -106,4 +106,8 @@ export class WorkbenchEditorTestService implements IEditorService {
invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
return undefined;
}
getOpened(editor: IResourceInput | IUntitledResourceInput, group?: IEditorGroup | GroupIdentifier): IEditorInput {
return undefined;
}
}

View File

@@ -7,7 +7,6 @@
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IConfigurationData, IConfigurationOverrides, ConfigurationTarget, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { TPromise } from 'vs/base/common/winjs.base';
import { Event } from 'vs/base/common/event';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
@@ -19,7 +18,7 @@ export class WorkspaceConfigurationTestService implements IWorkspaceConfiguratio
getValue<T>(overrides: IConfigurationOverrides): T;
getValue<T>(section: string, overrides: IConfigurationOverrides): T;
getValue(arg1?: any, arg2?: any): any {
return TPromise.as(null);
return Promise.resolve(null);
}
onDidChangeConfiguration: Event<IConfigurationChangeEvent>;
@@ -31,20 +30,20 @@ export class WorkspaceConfigurationTestService implements IWorkspaceConfiguratio
getConfiguration<T>(overrides: IConfigurationOverrides): T;
getConfiguration<T>(section: string, overrides: IConfigurationOverrides): T;
getConfiguration(arg1?: any, arg2?: any): any {
return TPromise.as(null);
return Promise.resolve(null);
}
updateValue(key: string, value: any): TPromise<void>;
updateValue(key: string, value: any, overrides: IConfigurationOverrides): TPromise<void>;
updateValue(key: string, value: any, target: ConfigurationTarget): TPromise<void>;
updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget): TPromise<void>;
updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget, donotNotifyError: boolean): TPromise<void>;
updateValue(key: string, value: any, arg3?: any, arg4?: any, donotNotifyError?: any): TPromise<void> {
return TPromise.as(null);
updateValue(key: string, value: any): Promise<void>;
updateValue(key: string, value: any, overrides: IConfigurationOverrides): Promise<void>;
updateValue(key: string, value: any, target: ConfigurationTarget): Promise<void>;
updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget): Promise<void>;
updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget, donotNotifyError: boolean): Promise<void>;
updateValue(key: string, value: any, arg3?: any, arg4?: any, donotNotifyError?: any): Promise<void> {
return Promise.resolve(null);
}
reloadConfiguration(folder?: IWorkspaceFolder, key?: string): TPromise<void> {
return TPromise.as(null);
reloadConfiguration(folder?: IWorkspaceFolder, key?: string): Promise<void> {
return Promise.resolve(null);
}
inspect<T>(key: string): {

View File

@@ -1,7 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

View File

@@ -9,7 +9,7 @@ import * as vscode from 'vscode';
import * as assert from 'assert';
import * as TypeMoq from 'typemoq';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostNotebook } from 'sql/workbench/api/node/extHostNotebook';

View File

@@ -9,7 +9,7 @@ import * as TypeMoq from 'typemoq';
import * as sqlops from 'sqlops';
import * as vscode from 'vscode';
import URI, { UriComponents } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostNotebookShape } from 'sql/workbench/api/node/sqlExtHost.protocol';

View File

@@ -13,7 +13,7 @@ import { TestConnectionManagementService } from 'sqltest/stubs/connectionManagem
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { WorkbenchEditorTestService } from 'sqltest/stubs/workbenchEditorTestService';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import { QueryInput } from 'sql/parts/query/common/queryInput';
@@ -76,7 +76,7 @@ suite('TaskUtilities', function () {
mockConnectionManagementService.setup(x => x.isProfileConnected(TypeMoq.It.is(profile => profile === oeProfile || profile === tabProfile))).returns(() => true);
// Mock the workbench service to return the active tab connection
let tabConnectionUri = 'test_uri';
let tabConnectionUri = 'file://test_uri';
let editorInput = new UntitledEditorInput(URI.parse(tabConnectionUri), false, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
let queryInput = new QueryInput(undefined, editorInput, undefined, undefined, undefined, undefined, undefined, undefined);
mockConnectionManagementService.setup(x => x.getConnectionProfile(tabConnectionUri)).returns(() => tabProfile);