diff --git a/extensions/sql-database-projects/README.md b/extensions/sql-database-projects/README.md index 609deccd16..4d33610f0e 100644 --- a/extensions/sql-database-projects/README.md +++ b/extensions/sql-database-projects/README.md @@ -3,7 +3,7 @@ Microsoft SQL Server Database Projects for Azure Data Studio includes: ## Database Projects -The Database Projects extension provides a way to design, edit, and deploy schemas for SQL databases from a source controlled project. +The Database Projects extension provides a way to design, edit, and publish schemas for SQL databases from a source controlled project. Please report issues and feature requests [here.](https://github.com/microsoft/azuredatastudio/issues) diff --git a/extensions/sql-database-projects/package.json b/extensions/sql-database-projects/package.json index 48349cc96e..eab3a66aad 100644 --- a/extensions/sql-database-projects/package.json +++ b/extensions/sql-database-projects/package.json @@ -1,7 +1,7 @@ { "name": "sql-database-projects", "displayName": "SQL Database Projects", - "description": "The SQL Database Projects extension for Azure Data Studio allows users to develop and deploy database schemas.", + "description": "The SQL Database Projects extension for Azure Data Studio allows users to develop and publish database schemas.", "version": "0.1.1", "publisher": "Microsoft", "preview": true, @@ -101,8 +101,8 @@ "category": "%sqlDatabaseProjects.displayName%" }, { - "command": "sqlDatabaseProjects.deploy", - "title": "%sqlDatabaseProjects.deploy%", + "command": "sqlDatabaseProjects.publish", + "title": "%sqlDatabaseProjects.publish%", "category": "%sqlDatabaseProjects.displayName%" }, { @@ -171,7 +171,7 @@ "when": "false" }, { - "command": "sqlDatabaseProjects.deploy", + "command": "sqlDatabaseProjects.publish", "when": "false" }, { @@ -197,7 +197,7 @@ "group": "1_dbProjectsFirst@1" }, { - "command": "sqlDatabaseProjects.deploy", + "command": "sqlDatabaseProjects.publish", "when": "view == sqlDatabaseProjectsView && viewItem == databaseProject.itemType.project", "group": "1_dbProjectsFirst@2" }, diff --git a/extensions/sql-database-projects/package.nls.json b/extensions/sql-database-projects/package.nls.json index 4528e89e94..f8fe0a9859 100644 --- a/extensions/sql-database-projects/package.nls.json +++ b/extensions/sql-database-projects/package.nls.json @@ -7,7 +7,7 @@ "sqlDatabaseProjects.open": "Open Database Project", "sqlDatabaseProjects.close": "Close Database Project", "sqlDatabaseProjects.build": "Build", - "sqlDatabaseProjects.deploy": "Publish", + "sqlDatabaseProjects.publish": "Publish", "sqlDatabaseProjects.importDatabase": "Import New Database Project", "sqlDatabaseProjects.properties": "Properties", "sqlDatabaseProjects.schemaCompare": "Schema Compare", diff --git a/extensions/sql-database-projects/src/common/constants.ts b/extensions/sql-database-projects/src/common/constants.ts index 24e93e2089..6eee7823d2 100644 --- a/extensions/sql-database-projects/src/common/constants.ts +++ b/extensions/sql-database-projects/src/common/constants.ts @@ -53,15 +53,14 @@ export function deleteConfirmation(toDelete: string) { return localize('deleteCo export function deleteConfirmationContents(toDelete: string) { return localize('deleteConfirmationContents', "Are you sure you want to delete {0} and all of its contents?", toDelete); } -// Deploy dialog strings +// Publish dialog strings -export const deployDialogName = localize('deployDialogName', "Publish Database"); -export const deployDialogOkButtonText = localize('deployDialogOkButtonText', "Publish"); +export const publishDialogName = localize('publishDialogName', "Publish Database"); +export const publishDialogOkButtonText = localize('publishDialogOkButtonText', "Publish"); export const cancelButtonText = localize('cancelButtonText', "Cancel"); export const generateScriptButtonText = localize('generateScriptButtonText', "Generate Script"); export const targetDatabaseSettings = localize('targetDatabaseSettings', "Target Database Settings"); export const databaseNameLabel = localize('databaseNameLabel', "Database"); -export const deployScriptNameLabel = localize('deployScriptName', "Publish script name"); export const targetConnectionLabel = localize('targetConnectionLabel', "Target Connection"); export const editConnectionButtonText = localize('editConnectionButtonText', "Edit"); export const clearButtonText = localize('clearButtonText', "Clear"); @@ -101,7 +100,7 @@ export const databaseNameRequired = localize('databaseNameRequired', "Database n export const invalidDataSchemaProvider = localize('invalidDataSchemaProvider', "Invalid DSP in .sqlproj file"); export const invalidDatabaseReference = localize('invalidDatabaseReference', "Invalid database reference in .sqlproj file"); export const databaseSelectionRequired = localize('databaseSelectionRequired', "Database selection is required to import a project"); -export const unableToCreateDeploymentConnection = localize('unableToCreateDeploymentConnection', "Unable to construct connection"); +export const unableToCreatePublishConnection = localize('unableToCreatePublishConnection', "Unable to construct connection"); export const databaseReferenceAlreadyExists = localize('databaseReferenceAlreadyExists', "A reference to this database already exists in this project"); export function projectAlreadyOpened(path: string) { return localize('projectAlreadyOpened', "Project '{0}' is already opened.", path); } export function projectAlreadyExists(name: string, path: string) { return localize('projectAlreadyExists', "A project named {0} already exists in {1}.", name, path); } diff --git a/extensions/sql-database-projects/src/controllers/mainController.ts b/extensions/sql-database-projects/src/controllers/mainController.ts index 733d7f705c..6f03c798cb 100644 --- a/extensions/sql-database-projects/src/controllers/mainController.ts +++ b/extensions/sql-database-projects/src/controllers/mainController.ts @@ -52,7 +52,7 @@ export default class MainController implements Disposable { this.apiWrapper.registerCommand('sqlDatabaseProjects.properties', async (node: BaseProjectTreeItem) => { await this.apiWrapper.showErrorMessage(`Properties not yet implemented: ${node.uri.path}`); }); // TODO this.apiWrapper.registerCommand('sqlDatabaseProjects.build', async (node: BaseProjectTreeItem) => { await this.projectsController.buildProject(node); }); - this.apiWrapper.registerCommand('sqlDatabaseProjects.deploy', async (node: BaseProjectTreeItem) => { await this.projectsController.deployProject(node); }); + this.apiWrapper.registerCommand('sqlDatabaseProjects.publish', async (node: BaseProjectTreeItem) => { await this.projectsController.publishProject(node); }); this.apiWrapper.registerCommand('sqlDatabaseProjects.schemaCompare', async (node: BaseProjectTreeItem) => { await this.projectsController.schemaCompare(node); }); this.apiWrapper.registerCommand('sqlDatabaseProjects.importDatabase', async (profile: azdata.IConnectionProfile) => { await this.projectsController.importNewDatabaseProject(profile); }); diff --git a/extensions/sql-database-projects/src/controllers/projectController.ts b/extensions/sql-database-projects/src/controllers/projectController.ts index 709cf2c1bd..554c05dc24 100644 --- a/extensions/sql-database-projects/src/controllers/projectController.ts +++ b/extensions/sql-database-projects/src/controllers/projectController.ts @@ -17,11 +17,11 @@ import { Uri, QuickPickItem, WorkspaceFolder, extensions, Extension } from 'vsco import { IConnectionProfile, TaskExecutionMode } from 'azdata'; import { promises as fs } from 'fs'; import { ApiWrapper } from '../common/apiWrapper'; -import { DeployDatabaseDialog } from '../dialogs/deployDatabaseDialog'; +import { PublishDatabaseDialog } from '../dialogs/publishDatabaseDialog'; import { Project, DatabaseReferenceLocation, SystemDatabase, TargetPlatform, ProjectEntry, reservedProjectFolders } from '../models/project'; import { SqlDatabaseProjectTreeViewProvider } from './databaseProjectTreeViewProvider'; import { FolderNode, FileNode } from '../models/tree/fileFolderTreeItem'; -import { IDeploymentProfile, IGenerateScriptProfile, PublishSettings } from '../models/IDeploymentProfile'; +import { IPublishSettings, IGenerateScriptSettings, PublishProfile } from '../models/IPublishSettings'; import { BaseProjectTreeItem } from '../models/tree/baseTreeItem'; import { ProjectRootTreeItem } from '../models/tree/projectTreeItem'; import { ImportDataModel } from '../models/api/import'; @@ -185,50 +185,50 @@ export class ProjectsController { } /** - * Builds and deploys a project + * Builds and publishes a project * @param treeNode a treeItem in a project's hierarchy, to be used to obtain a Project */ - public async deployProject(treeNode: BaseProjectTreeItem): Promise; + public async publishProject(treeNode: BaseProjectTreeItem): Promise; /** - * Builds and deploys a project - * @param project Project to be built and deployed + * Builds and publishes a project + * @param project Project to be built and published */ - public async deployProject(project: Project): Promise; - public async deployProject(context: Project | BaseProjectTreeItem): Promise { + public async publishProject(project: Project): Promise; + public async publishProject(context: Project | BaseProjectTreeItem): Promise { const project: Project = this.getProjectFromContext(context); - let deployDatabaseDialog = this.getDeployDialog(project); + let publishDatabaseDialog = this.getPublishDialog(project); - deployDatabaseDialog.deploy = async (proj, prof) => await this.executionCallback(proj, prof); - deployDatabaseDialog.generateScript = async (proj, prof) => await this.executionCallback(proj, prof); - deployDatabaseDialog.readPublishProfile = async (profileUri) => await this.readPublishProfile(profileUri); + publishDatabaseDialog.publish = async (proj, prof) => await this.executionCallback(proj, prof); + publishDatabaseDialog.generateScript = async (proj, prof) => await this.executionCallback(proj, prof); + publishDatabaseDialog.readPublishProfile = async (profileUri) => await this.readPublishProfile(profileUri); - deployDatabaseDialog.openDialog(); + publishDatabaseDialog.openDialog(); - return deployDatabaseDialog; + return publishDatabaseDialog; } - public async executionCallback(project: Project, profile: IDeploymentProfile | IGenerateScriptProfile): Promise { + public async executionCallback(project: Project, settings: IPublishSettings | IGenerateScriptSettings): Promise { const dacpacPath = await this.buildProject(project); if (!dacpacPath) { return undefined; // buildProject() handles displaying the error } - // copy dacpac to temp location before deployment + // copy dacpac to temp location before publishing const tempPath = path.join(os.tmpdir(), `${path.parse(dacpacPath).name}_${new Date().getTime()}${constants.sqlprojExtension}`); await fs.copyFile(dacpacPath, tempPath); const dacFxService = await this.getDaxFxService(); - if ((profile).upgradeExisting) { - return await dacFxService.deployDacpac(tempPath, profile.databaseName, (profile).upgradeExisting, profile.connectionUri, TaskExecutionMode.execute, profile.sqlCmdVariables); + if ((settings).upgradeExisting) { + return await dacFxService.deployDacpac(tempPath, settings.databaseName, (settings).upgradeExisting, settings.connectionUri, TaskExecutionMode.execute, settings.sqlCmdVariables); } else { - return await dacFxService.generateDeployScript(tempPath, profile.databaseName, profile.connectionUri, TaskExecutionMode.script, profile.sqlCmdVariables); + return await dacFxService.generateDeployScript(tempPath, settings.databaseName, settings.connectionUri, TaskExecutionMode.script, settings.sqlCmdVariables); } } - public async readPublishProfile(profileUri: Uri): Promise { + public async readPublishProfile(profileUri: Uri): Promise { const profileText = await fs.readFile(profileUri.fsPath); const profileXmlDoc = new xmldom.DOMParser().parseFromString(profileText.toString()); @@ -544,8 +544,8 @@ export class ProjectsController { //#region Helper methods - public getDeployDialog(project: Project): DeployDatabaseDialog { - return new DeployDatabaseDialog(this.apiWrapper, project); + public getPublishDialog(project: Project): PublishDatabaseDialog { + return new PublishDatabaseDialog(this.apiWrapper, project); } public async updateProjectForRoundTrip(project: Project) { diff --git a/extensions/sql-database-projects/src/dialogs/deployDatabaseDialog.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts similarity index 92% rename from extensions/sql-database-projects/src/dialogs/deployDatabaseDialog.ts rename to extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts index 81b81be227..6ddc305478 100644 --- a/extensions/sql-database-projects/src/dialogs/deployDatabaseDialog.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts @@ -11,16 +11,16 @@ import * as utils from '../common/utils'; import { Project } from '../models/project'; import { SqlConnectionDataSource } from '../models/dataSources/sqlConnectionStringSource'; import { ApiWrapper } from '../common/apiWrapper'; -import { IDeploymentProfile, IGenerateScriptProfile } from '../models/IDeploymentProfile'; +import { IPublishSettings, IGenerateScriptSettings } from '../models/IPublishSettings'; interface DataSourceDropdownValue extends azdata.CategoryValue { dataSource: SqlConnectionDataSource; database: string; } -export class DeployDatabaseDialog { +export class PublishDatabaseDialog { public dialog: azdata.window.Dialog; - public deployTab: azdata.window.DialogTab; + public publishTab: azdata.window.DialogTab; private targetConnectionTextBox: azdata.InputBoxComponent | undefined; private targetConnectionFormComponent: azdata.FormComponent | undefined; private dataSourcesFormComponent: azdata.FormComponent | undefined; @@ -38,20 +38,20 @@ export class DeployDatabaseDialog { private toDispose: vscode.Disposable[] = []; - public deploy: ((proj: Project, profile: IDeploymentProfile) => any) | undefined; - public generateScript: ((proj: Project, profile: IGenerateScriptProfile) => any) | undefined; + public publish: ((proj: Project, profile: IPublishSettings) => any) | undefined; + public generateScript: ((proj: Project, profile: IGenerateScriptSettings) => any) | undefined; public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined; constructor(private apiWrapper: ApiWrapper, private project: Project) { - this.dialog = azdata.window.createModelViewDialog(constants.deployDialogName); - this.deployTab = azdata.window.createTab(constants.deployDialogName); + this.dialog = azdata.window.createModelViewDialog(constants.publishDialogName); + this.publishTab = azdata.window.createTab(constants.publishDialogName); } public openDialog(): void { this.initializeDialog(); - this.dialog.okButton.label = constants.deployDialogOkButtonText; + this.dialog.okButton.label = constants.publishDialogOkButtonText; this.dialog.okButton.enabled = false; - this.toDispose.push(this.dialog.okButton.onClick(async () => await this.deployClick())); + this.toDispose.push(this.dialog.okButton.onClick(async () => await this.publishClick())); this.dialog.cancelButton.label = constants.cancelButtonText; @@ -70,12 +70,12 @@ export class DeployDatabaseDialog { } private initializeDialog(): void { - this.initializeDeployTab(); - this.dialog.content = [this.deployTab]; + this.initializePublishTab(); + this.dialog.content = [this.publishTab]; } - private initializeDeployTab(): void { - this.deployTab.registerContent(async view => { + private initializePublishTab(): void { + this.publishTab.registerContent(async view => { // TODO : enable using this when data source creation is enabled this.createRadioButtons(view); @@ -189,13 +189,13 @@ export class DeployDatabaseDialog { return await this.apiWrapper.getUriForConnection(connId); } catch (err) { - throw new Error(constants.unableToCreateDeploymentConnection + ': ' + utils.getErrorMessage(err)); + throw new Error(constants.unableToCreatePublishConnection + ': ' + utils.getErrorMessage(err)); } } - public async deployClick(): Promise { - const sqlCmdVars = this.getSqlCmdVariablesForDeploy(); - const profile: IDeploymentProfile = { + public async publishClick(): Promise { + const sqlCmdVars = this.getSqlCmdVariablesForPublish(); + const settings: IPublishSettings = { databaseName: this.getTargetDatabaseName(), upgradeExisting: true, connectionUri: await this.getConnectionUri(), @@ -203,14 +203,14 @@ export class DeployDatabaseDialog { }; this.apiWrapper.closeDialog(this.dialog); - await this.deploy!(this.project, profile); + await this.publish!(this.project, settings); this.dispose(); } public async generateScriptClick(): Promise { - const sqlCmdVars = this.getSqlCmdVariablesForDeploy(); - const profile: IGenerateScriptProfile = { + const sqlCmdVars = this.getSqlCmdVariablesForPublish(); + const settings: IGenerateScriptSettings = { databaseName: this.getTargetDatabaseName(), connectionUri: await this.getConnectionUri(), sqlCmdVariables: sqlCmdVars @@ -219,13 +219,13 @@ export class DeployDatabaseDialog { this.apiWrapper.closeDialog(this.dialog); if (this.generateScript) { - await this.generateScript!(this.project, profile); + await this.generateScript!(this.project, settings); } this.dispose(); } - private getSqlCmdVariablesForDeploy(): Record { + private getSqlCmdVariablesForPublish(): Record { // get SQLCMD variables from project let sqlCmdVariables = { ...this.project.sqlCmdVariables }; @@ -421,7 +421,7 @@ export class DeployDatabaseDialog { const result = await this.readPublishProfile(fileUris[0]); (this.targetDatabaseTextBox).value = result.databaseName; this.profileSqlCmdVars = result.sqlCmdVariables; - const data = this.convertSqlCmdVarsToTableFormat(this.getSqlCmdVariablesForDeploy()); + const data = this.convertSqlCmdVarsToTableFormat(this.getSqlCmdVariablesForPublish()); (this.sqlCmdVariablesTable).updateProperties({ data: data diff --git a/extensions/sql-database-projects/src/models/IDeploymentProfile.ts b/extensions/sql-database-projects/src/models/IPublishSettings.ts similarity index 78% rename from extensions/sql-database-projects/src/models/IDeploymentProfile.ts rename to extensions/sql-database-projects/src/models/IPublishSettings.ts index 9ddf9561da..4e80761b72 100644 --- a/extensions/sql-database-projects/src/models/IDeploymentProfile.ts +++ b/extensions/sql-database-projects/src/models/IPublishSettings.ts @@ -3,20 +3,21 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -export interface IDeploymentProfile { +export interface IPublishSettings { databaseName: string; connectionUri: string; upgradeExisting: boolean; sqlCmdVariables?: Record; } -export interface IGenerateScriptProfile { +export interface IGenerateScriptSettings { databaseName: string; connectionUri: string; sqlCmdVariables?: Record; } -export interface PublishSettings { +// only reading db name and SQLCMD vars from profile for now +export interface PublishProfile { databaseName: string; sqlCmdVariables: Record; } diff --git a/extensions/sql-database-projects/src/test/projectController.test.ts b/extensions/sql-database-projects/src/test/projectController.test.ts index 83c116ef3d..9d688b7be2 100644 --- a/extensions/sql-database-projects/src/test/projectController.test.ts +++ b/extensions/sql-database-projects/src/test/projectController.test.ts @@ -19,9 +19,9 @@ import { ProjectsController } from '../controllers/projectController'; import { promises as fs } from 'fs'; import { createContext, TestContext, mockDacFxResult } from './testContext'; import { Project, SystemDatabase, ProjectEntry, reservedProjectFolders } from '../models/project'; -import { DeployDatabaseDialog } from '../dialogs/deployDatabaseDialog'; +import { PublishDatabaseDialog } from '../dialogs/publishDatabaseDialog'; import { ApiWrapper } from '../common/apiWrapper'; -import { IDeploymentProfile, IGenerateScriptProfile } from '../models/IDeploymentProfile'; +import { IPublishSettings, IGenerateScriptSettings } from '../models/IPublishSettings'; import { exists } from '../common/utils'; import { ProjectRootTreeItem } from '../models/tree/projectTreeItem'; import { FolderNode } from '../models/tree/fileFolderTreeItem'; @@ -219,41 +219,41 @@ describe('ProjectsController: project controller operations', function (): void }); }); - describe('Deployment and deployment script generation', function (): void { - it('Deploy dialog should open from ProjectController', async function (): Promise { + describe('Publishing and script generation', function (): void { + it('Publish dialog should open from ProjectController', async function (): Promise { let opened = false; - let deployDialog = TypeMoq.Mock.ofType(DeployDatabaseDialog); - deployDialog.setup(x => x.openDialog()).returns(() => { opened = true; }); + let publishDialog = TypeMoq.Mock.ofType(PublishDatabaseDialog); + publishDialog.setup(x => x.openDialog()).returns(() => { opened = true; }); let projController = TypeMoq.Mock.ofType(ProjectsController); projController.callBase = true; - projController.setup(x => x.getDeployDialog(TypeMoq.It.isAny())).returns(() => deployDialog.object); + projController.setup(x => x.getPublishDialog(TypeMoq.It.isAny())).returns(() => publishDialog.object); - await projController.object.deployProject(new Project('FakePath')); + await projController.object.publishProject(new Project('FakePath')); should(opened).equal(true); }); - it('Callbacks are hooked up and called from Deploy dialog', async function (): Promise { + it('Callbacks are hooked up and called from Publish dialog', async function (): Promise { const projPath = path.dirname(await testUtils.createTestSqlProjFile(baselines.openProjectFileBaseline)); await testUtils.createTestDataSources(baselines.openDataSourcesBaseline, projPath); const proj = new Project(projPath); - const deployHoller = 'hello from callback for deploy()'; + const publishHoller = 'hello from callback for publish()'; const generateHoller = 'hello from callback for generateScript()'; const profileHoller = 'hello from callback for readPublishProfile()'; let holler = 'nothing'; - let deployDialog = TypeMoq.Mock.ofType(DeployDatabaseDialog, undefined, undefined, new ApiWrapper(), proj); - deployDialog.callBase = true; - deployDialog.setup(x => x.getConnectionUri()).returns(async () => 'fake|connection|uri'); + let publishDialog = TypeMoq.Mock.ofType(PublishDatabaseDialog, undefined, undefined, new ApiWrapper(), proj); + publishDialog.callBase = true; + publishDialog.setup(x => x.getConnectionUri()).returns(async () => 'fake|connection|uri'); let projController = TypeMoq.Mock.ofType(ProjectsController); projController.callBase = true; - projController.setup(x => x.getDeployDialog(TypeMoq.It.isAny())).returns(() => deployDialog.object); - projController.setup(x => x.executionCallback(TypeMoq.It.isAny(), TypeMoq.It.is((_): _ is IDeploymentProfile => true))).returns(async () => { - holler = deployHoller; + projController.setup(x => x.getPublishDialog(TypeMoq.It.isAny())).returns(() => publishDialog.object); + projController.setup(x => x.executionCallback(TypeMoq.It.isAny(), TypeMoq.It.is((_): _ is IPublishSettings => true))).returns(async () => { + holler = publishHoller; return undefined; }); projController.setup(x => x.readPublishProfile(TypeMoq.It.isAny())).returns(async () => { @@ -264,22 +264,22 @@ describe('ProjectsController: project controller operations', function (): void }; }); - projController.setup(x => x.executionCallback(TypeMoq.It.isAny(), TypeMoq.It.is((_): _ is IGenerateScriptProfile => true))).returns(async () => { + projController.setup(x => x.executionCallback(TypeMoq.It.isAny(), TypeMoq.It.is((_): _ is IGenerateScriptSettings => true))).returns(async () => { holler = generateHoller; return undefined; }); - let dialog = await projController.object.deployProject(proj); - await dialog.deployClick(); + let dialog = await projController.object.publishProject(proj); + await dialog.publishClick(); - should(holler).equal(deployHoller, 'executionCallback() is supposed to have been setup and called for Deploy scenario'); + should(holler).equal(publishHoller, 'executionCallback() is supposed to have been setup and called for Publish scenario'); - dialog = await projController.object.deployProject(proj); + dialog = await projController.object.publishProject(proj); await dialog.generateScriptClick(); should(holler).equal(generateHoller, 'executionCallback() is supposed to have been setup and called for GenerateScript scenario'); - dialog = await projController.object.deployProject(proj); + dialog = await projController.object.publishProject(proj); await projController.object.readPublishProfile(vscode.Uri.parse('test')); should(holler).equal(profileHoller, 'executionCallback() is supposed to have been setup and called for ReadPublishProfile scenario'); @@ -296,15 +296,15 @@ describe('ProjectsController: project controller operations', function (): void should(result.sqlCmdVariables['ProdDatabaseName']).equal('MyProdDatabase'); }); - it('Should copy dacpac to temp folder before deploying', async function (): Promise { + it('Should copy dacpac to temp folder before publishing', async function (): Promise { const fakeDacpacContents = 'SwiftFlewHiawathasArrow'; let postCopyContents = ''; let builtDacpacPath = ''; - let deployedDacpacPath = ''; + let publishedDacpacPath = ''; testContext.dacFxService.setup(x => x.generateDeployScript(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(async (p) => { - deployedDacpacPath = p; - postCopyContents = (await fs.readFile(deployedDacpacPath)).toString(); + publishedDacpacPath = p; + postCopyContents = (await fs.readFile(publishedDacpacPath)).toString(); return Promise.resolve(mockDacFxResult); }); @@ -321,9 +321,9 @@ describe('ProjectsController: project controller operations', function (): void await projController.object.executionCallback(new Project(''), { connectionUri: '', databaseName: '' }); should(builtDacpacPath).not.equal('', 'built dacpac path should be set'); - should(deployedDacpacPath).not.equal('', 'deployed dacpac path should be set'); - should(builtDacpacPath).not.equal(deployedDacpacPath, 'built and deployed dacpac paths should be different'); - should(postCopyContents).equal(fakeDacpacContents, 'contents of built and deployed dacpacs should match'); + should(publishedDacpacPath).not.equal('', 'published dacpac path should be set'); + should(builtDacpacPath).not.equal(publishedDacpacPath, 'built and published dacpac paths should be different'); + should(postCopyContents).equal(fakeDacpacContents, 'contents of built and published dacpacs should match'); }); }); }); diff --git a/extensions/sql-database-projects/src/test/deployDatabaseDialog.test.ts b/extensions/sql-database-projects/src/test/publishDatabaseDialog.test.ts similarity index 72% rename from extensions/sql-database-projects/src/test/deployDatabaseDialog.test.ts rename to extensions/sql-database-projects/src/test/publishDatabaseDialog.test.ts index ec2d64b22c..f08b2cbac5 100644 --- a/extensions/sql-database-projects/src/test/deployDatabaseDialog.test.ts +++ b/extensions/sql-database-projects/src/test/publishDatabaseDialog.test.ts @@ -9,20 +9,20 @@ import * as os from 'os'; import * as vscode from 'vscode'; import * as baselines from './baselines/baselines'; import * as templates from '../templates/templates'; -import * as testUtils from '../test/testUtils'; +import * as testUtils from './testUtils'; import * as TypeMoq from 'typemoq'; -import { DeployDatabaseDialog } from '../dialogs/deployDatabaseDialog'; +import { PublishDatabaseDialog } from '../dialogs/publishDatabaseDialog'; import { Project } from '../models/project'; import { SqlDatabaseProjectTreeViewProvider } from '../controllers/databaseProjectTreeViewProvider'; import { ProjectsController } from '../controllers/projectController'; import { createContext, TestContext } from './testContext'; -import { IDeploymentProfile, IGenerateScriptProfile } from '../models/IDeploymentProfile'; +import { IPublishSettings, IGenerateScriptSettings } from '../models/IPublishSettings'; let testContext: TestContext; -describe.skip('Deploy Database Dialog', () => { +describe.skip('Publish Database Dialog', () => { before(async function (): Promise { await templates.loadTemplates(path.join(__dirname, '..', '..', 'resources', 'templates')); await baselines.loadBaselines(); @@ -38,9 +38,9 @@ describe.skip('Deploy Database Dialog', () => { const projFilePath = await projController.createNewProject('TestProjectName', vscode.Uri.file(projFileDir), true, 'BA5EBA11-C0DE-5EA7-ACED-BABB1E70A575'); const project = new Project(projFilePath); - const deployDatabaseDialog = new DeployDatabaseDialog(testContext.apiWrapper.object, project); - deployDatabaseDialog.openDialog(); - should.notEqual(deployDatabaseDialog.deployTab, undefined); + const publishDatabaseDialog = new PublishDatabaseDialog(testContext.apiWrapper.object, project); + publishDatabaseDialog.openDialog(); + should.notEqual(publishDatabaseDialog.publishTab, undefined); }); it('Should create default database name correctly ', async function (): Promise { @@ -51,20 +51,20 @@ describe.skip('Deploy Database Dialog', () => { const projFilePath = await projController.createNewProject('TestProjectName', vscode.Uri.file(projFileDir), true, 'BA5EBA11-C0DE-5EA7-ACED-BABB1E70A575'); const project = new Project(projFilePath); - const deployDatabaseDialog = new DeployDatabaseDialog(testContext.apiWrapper.object, project); - should.equal(deployDatabaseDialog.getDefaultDatabaseName(), project.projectFileName); + const publishDatabaseDialog = new PublishDatabaseDialog(testContext.apiWrapper.object, project); + should.equal(publishDatabaseDialog.getDefaultDatabaseName(), project.projectFileName); }); - it('Should include all info in deployment profile', async function (): Promise { + it('Should include all info in publish profile', async function (): Promise { const proj = await testUtils.createTestProject(baselines.openProjectFileBaseline); - const dialog = TypeMoq.Mock.ofType(DeployDatabaseDialog, undefined, undefined, testContext.apiWrapper.object, proj); + const dialog = TypeMoq.Mock.ofType(PublishDatabaseDialog, undefined, undefined, testContext.apiWrapper.object, proj); dialog.setup(x => x.getConnectionUri()).returns(async () => { return 'Mock|Connection|Uri'; }); dialog.setup(x => x.getTargetDatabaseName()).returns(() => 'MockDatabaseName'); dialog.callBase = true; - let profile: IDeploymentProfile | IGenerateScriptProfile | undefined; + let profile: IPublishSettings | IGenerateScriptSettings | undefined; - const expectedDeploy: IDeploymentProfile = { + const expectedPublish: IPublishSettings = { databaseName: 'MockDatabaseName', connectionUri: 'Mock|Connection|Uri', upgradeExisting: true, @@ -74,12 +74,12 @@ describe.skip('Deploy Database Dialog', () => { } }; - dialog.object.deploy = async (_, prof) => { profile = prof; }; - await dialog.object.deployClick(); + dialog.object.publish = async (_, prof) => { profile = prof; }; + await dialog.object.publishClick(); - should(profile).deepEqual(expectedDeploy); + should(profile).deepEqual(expectedPublish); - const expectedGenScript: IGenerateScriptProfile = { + const expectedGenScript: IGenerateScriptSettings = { databaseName: 'MockDatabaseName', connectionUri: 'Mock|Connection|Uri', sqlCmdVariables: {