mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
Initial Pre-post deployment changes (#11703)
* Update Open Project to display pre-post deployment scripts in the project tree * Address comments * Fixed tests * Update nonDeployScripts to noneDeployScripts and throw a warning message instead of informational message for prePostDeployCount
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as should from 'should';
|
||||
import * as path from 'path';
|
||||
import * as sinon from 'sinon';
|
||||
import * as baselines from './baselines/baselines';
|
||||
import * as testUtils from './testUtils';
|
||||
import * as constants from '../common/constants';
|
||||
@@ -12,7 +13,7 @@ import * as constants from '../common/constants';
|
||||
import { promises as fs } from 'fs';
|
||||
import { Project, EntryType, TargetPlatform, SystemDatabase, DatabaseReferenceLocation, DacpacReferenceProjectEntry, SqlProjectReferenceProjectEntry } from '../models/project';
|
||||
import { exists, convertSlashesForSqlProj } from '../common/utils';
|
||||
import { Uri } from 'vscode';
|
||||
import { Uri, window } from 'vscode';
|
||||
|
||||
let projFilePath: string;
|
||||
|
||||
@@ -46,6 +47,15 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
should(project.databaseReferences.length).equal(1);
|
||||
should(project.databaseReferences[0].databaseName).containEql(constants.master);
|
||||
should(project.databaseReferences[0] instanceof DacpacReferenceProjectEntry).equal(true);
|
||||
|
||||
// Pre-post deployment scripts
|
||||
should(project.preDeployScripts.length).equal(1);
|
||||
should(project.postDeployScripts.length).equal(1);
|
||||
should(project.noneDeployScripts.length).equal(2);
|
||||
should(project.preDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Script.PreDeployment1.sql')).not.equal(undefined, 'File Script.PreDeployment1.sql not read');
|
||||
should(project.postDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Script.PostDeployment1.sql')).not.equal(undefined, 'File Script.PostDeployment1.sql not read');
|
||||
should(project.noneDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Script.PreDeployment2.sql')).not.equal(undefined, 'File Script.PostDeployment2.sql not read');
|
||||
should(project.noneDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Tables\\Script.PostDeployment1.sql')).not.equal(undefined, 'File Tables\\Script.PostDeployment1.sql not read');
|
||||
});
|
||||
|
||||
it('Should read Project with Project reference from sqlproj', async function (): Promise<void> {
|
||||
@@ -61,6 +71,24 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
should(project.databaseReferences[1] instanceof SqlProjectReferenceProjectEntry).equal(true);
|
||||
});
|
||||
|
||||
it('Should throw warning message while reading Project with more than 1 pre-deploy script from sqlproj', async function (): Promise<void> {
|
||||
const stub = sinon.stub(window, 'showWarningMessage').returns(<any>Promise.resolve(constants.okString));
|
||||
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.openSqlProjectWithPrePostDeploymentError);
|
||||
const project: Project = await Project.openProject(projFilePath);
|
||||
|
||||
should(stub.calledOnce).be.true('showWarningMessage should have been called exactly once');
|
||||
should(stub.calledWith(constants.prePostDeployCount)).be.true(`showWarningMessage not called with expected message '${constants.prePostDeployCount}' Actual '${stub.getCall(0).args[0]}'`);
|
||||
|
||||
should(project.preDeployScripts.length).equal(2);
|
||||
should(project.postDeployScripts.length).equal(1);
|
||||
should(project.noneDeployScripts.length).equal(1);
|
||||
should(project.preDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Script.PreDeployment1.sql')).not.equal(undefined, 'File Script.PreDeployment1.sql not read');
|
||||
should(project.postDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Script.PostDeployment1.sql')).not.equal(undefined, 'File Script.PostDeployment1.sql not read');
|
||||
should(project.preDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Script.PreDeployment2.sql')).not.equal(undefined, 'File Script.PostDeployment2.sql not read');
|
||||
should(project.noneDeployScripts.find(f => f.type === EntryType.File && f.relativePath === 'Tables\\Script.PostDeployment1.sql')).not.equal(undefined, 'File Tables\\Script.PostDeployment1.sql not read');
|
||||
});
|
||||
|
||||
it('Should add Folder and Build entries to sqlproj', async function (): Promise<void> {
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user