Change deploy to publish in sql project codebase (#11144)

* change deploy to publish

* rename to IPublishSettings

* change a few more profiles to settings
This commit is contained in:
Kim Santiago
2020-06-30 19:23:03 -07:00
committed by GitHub
parent 2b5ae5e3a8
commit 1e805a4156
10 changed files with 107 additions and 107 deletions

View File

@@ -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<void> {
describe('Publishing and script generation', function (): void {
it('Publish dialog should open from ProjectController', async function (): Promise<void> {
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<void> {
it('Callbacks are hooked up and called from Publish dialog', async function (): Promise<void> {
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<void> {
it('Should copy dacpac to temp folder before publishing', async function (): Promise<void> {
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');
});
});
});

View File

@@ -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<void> {
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<void> {
@@ -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<void> {
it('Should include all info in publish profile', async function (): Promise<void> {
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: {