diff --git a/src/sql/workbench/services/commandLine/common/commandLineService.ts b/src/sql/workbench/services/commandLine/common/commandLineService.ts index b095ac7946..061468dee2 100644 --- a/src/sql/workbench/services/commandLine/common/commandLineService.ts +++ b/src/sql/workbench/services/commandLine/common/commandLineService.ts @@ -36,7 +36,9 @@ export class CommandLineService implements ICommandLineProcessing { ipc.on('ads:processCommandLine', (event: any, args: ParsedArgs) => this.onLaunched(args)); } // we only get the ipc from main during window reuse - this.onLaunched(_environmentService.args); + if (_environmentService) { + this.onLaunched(_environmentService.args); + } } private onLaunched(args: ParsedArgs) diff --git a/src/sqltest/parts/commandLine/commandLineService.test.ts b/src/sqltest/parts/commandLine/commandLineService.test.ts index a7ce7290e8..f6c8e9c5b0 100644 --- a/src/sqltest/parts/commandLine/commandLineService.test.ts +++ b/src/sqltest/parts/commandLine/commandLineService.test.ts @@ -2,20 +2,15 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as azdata from 'azdata'; - /* 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'; -import { TPromise } from 'vs/base/common/winjs.base'; import * as assert from 'assert'; import * as TypeMoq from 'typemoq'; import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; import { CommandLineService } from 'sql/workbench/services/commandLine/common/commandLineService'; -import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; -import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; +import { ParsedArgs } from 'vs/platform/environment/common/environment'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService'; import { QueryEditorService } from 'sql/workbench/services/queryEditor/browser/queryEditorService'; @@ -96,7 +91,6 @@ suite('commandLineService tests', () => { let capabilitiesService: CapabilitiesTestService; let commandLineService: CommandLineService; - let environmentService: TypeMoq.Mock; let queryEditorService: TypeMoq.Mock; let editorService: TypeMoq.Mock; let objectExplorerService: TypeMoq.Mock; @@ -215,7 +209,7 @@ suite('commandLineService tests', () => { connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.isAny(), TypeMoq.It.isAny())) .verifiable(TypeMoq.Times.never()); commandService.setup(c => c.executeCommand('mycommand')) - .returns(() => TPromise.wrap(1)) + .returns(() => Promise.resolve()) .verifiable(TypeMoq.Times.once()); const configurationService = getConfigurationServiceMock(true); let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object); @@ -236,14 +230,13 @@ suite('commandLineService tests', () => { const args: TestParsedArgs = new TestParsedArgs(); args.command = 'mycommand'; args.server = 'myserver'; - environmentService.setup(e => e.args).returns(() => args); connectionManagementService.setup((c) => c.showConnectionDialog()).verifiable(TypeMoq.Times.never()); connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce()); connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is(p => p.serverName === 'myserver'), 'connection', true)) .returns(() => new Promise((resolve, reject) => { resolve('unused'); })) .verifiable(TypeMoq.Times.once()); commandService.setup(c => c.executeCommand('mycommand', TypeMoq.It.isAnyString())) - .returns(() => TPromise.wrap(1)) + .returns(() => Promise.resolve()) .verifiable(TypeMoq.Times.once()); const configurationService = getConfigurationServiceMock(true); let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object); @@ -261,10 +254,9 @@ suite('commandLineService tests', () => { const args: TestParsedArgs = new TestParsedArgs(); args.command = 'mycommand'; - environmentService.setup(e => e.args).returns(() => args); connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true); commandService.setup(c => c.executeCommand('mycommand')) - .returns(() => TPromise.wrapError(new Error('myerror'))) + .returns(() => Promise.reject(new Error('myerror'))) .verifiable(TypeMoq.Times.once()); const configurationService = getConfigurationServiceMock(true); let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object); @@ -278,4 +270,3 @@ suite('commandLineService tests', () => { }); }); -*/ \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 1587fed666..094a2d1252 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1673,6 +1673,7 @@ combined-stream@^1.0.5, combined-stream@~1.0.5: combined-stream@^1.0.6, combined-stream@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" + integrity sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w== dependencies: delayed-stream "~1.0.0"