Add publish profile to sql proj and tree (#22008)

* Read publish profiles stored in sqlproj file and present it in the projects tree

* Save publish profile and add it to sqlproj file, and present it in the tree

* Fix context menu operations

* Add tests

* Address comments
This commit is contained in:
Sakshi Sharma
2023-02-23 22:32:12 -08:00
committed by GitHub
parent 91cdd610fd
commit 41e2767880
11 changed files with 267 additions and 14 deletions

View File

@@ -66,6 +66,12 @@ describe('Project: sqlproj content operations', function (): void {
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');
// Publish profiles
should(project.publishProfiles.length).equal(3);
should(project.publishProfiles.find(f => f.type === EntryType.File && f.relativePath === 'TestProjectName_1.publish.xml')).not.equal(undefined, 'Profile TestProjectName_1.publish.xml not read');
should(project.publishProfiles.find(f => f.type === EntryType.File && f.relativePath === 'TestProjectName_2.publish.xml')).not.equal(undefined, 'Profile TestProjectName_2.publish.xml not read');
should(project.publishProfiles.find(f => f.type === EntryType.File && f.relativePath === 'TestProjectName_3.publish.xml')).not.equal(undefined, 'Profile TestProjectName_3.publish.xml not read');
});
it('Should read Project with Project reference from sqlproj', async function (): Promise<void> {
@@ -1592,6 +1598,30 @@ describe('Project: add SQLCMD Variables', function (): void {
});
});
describe('Project: add publish profiles', function (): void {
before(async function (): Promise<void> {
await baselines.loadBaselines();
});
after(async function (): Promise<void> {
await testUtils.deleteGeneratedTestFolder();
});
it('Should update .sqlproj with new publish profiles', async function (): Promise<void> {
projFilePath = await testUtils.createTestSqlProjFile(baselines.openProjectFileBaseline);
const project = await Project.openProject(projFilePath);
should(Object.keys(project.publishProfiles).length).equal(3);
// add a new publish profile
await project.addPublishProfileToProjFile(path.join(projFilePath, 'TestProjectName_4.publish.xml'));
should(Object.keys(project.publishProfiles).length).equal(4);
const projFileText = (await fs.readFile(projFilePath)).toString();
should(projFileText).equal(baselines.openSqlProjectWithAdditionalPublishProfileBaseline.trim());
});
});
describe('Project: properties', function (): void {
before(async function (): Promise<void> {
await baselines.loadBaselines();