Tests for round tripping with SSDT projects (#10646)

* Test code for round tripping feature

* Fixed tests. Edited updateImportedTargetsToProjFile method to push newly added import target to the list.

* Added couple more tests

* Addressed comment
This commit is contained in:
Sakshi Sharma
2020-06-03 14:02:50 -07:00
committed by GitHub
parent 3860f07cab
commit c903112451
8 changed files with 260 additions and 20 deletions

View File

@@ -10,6 +10,7 @@ import * as testUtils from './testUtils';
import { promises as fs } from 'fs';
import { Project, EntryType } from '../models/project';
import { exists } from '../common/utils';
let projFilePath: string;
@@ -82,3 +83,23 @@ describe('Project: sqlproj content operations', function (): void {
await testUtils.shouldThrowSpecificError(async () => await project.addToProject(list), `ENOENT: no such file or directory, stat \'${nonexistentFile}\'`);
});
});
describe('Project: round trip updates', function (): void {
before(async function () : Promise<void> {
await baselines.loadBaselines();
});
it('Should update SSDT project to work in ADS', async function (): Promise<void> {
projFilePath = await testUtils.createTestSqlProjFile(baselines.SSDTProjectFileBaseline);
const project: Project = new Project(projFilePath);
await project.readProjFile();
await project.updateProjectForRoundTrip();
should(await exists(projFilePath + '_backup')).equal(true); // backup file should be generated before the project is updated
should(project.importedTargets.length).equal(3); // additional target added by updateProjectForRoundTrip method
let projFileText = (await fs.readFile(projFilePath)).toString();
should(projFileText).equal(baselines.SSDTProjectAfterUpdateBaseline.trim());
});
});