Enable sql-database-projects tests with few fixes (#10610)

* Added 2tests related to import. Fixed a few issues. Enable sql-database-projects

* Addressed comment
This commit is contained in:
Sakshi Sharma
2020-05-30 09:05:55 -07:00
committed by GitHub
parent 7d31239e64
commit 84492049e8
5 changed files with 50 additions and 15 deletions

View File

@@ -14,7 +14,7 @@ import { Project, EntryType } from '../models/project';
let projFilePath: string;
describe('Project: sqlproj content operations', function (): void {
before(async function () : Promise<void> {
before(async function() : Promise<void> {
await baselines.loadBaselines();
});
@@ -52,7 +52,7 @@ describe('Project: sqlproj content operations', function (): void {
const newFileContents = (await fs.readFile(path.join(newProject.projectFolderPath, filePath))).toString();
should (newFileContents).equal(fileContents);
should(newFileContents).equal(fileContents);
});
it('Should add Folder and Build entries to sqlproj with pre-existing scripts on disk', async function (): Promise<void> {
@@ -65,6 +65,20 @@ describe('Project: sqlproj content operations', function (): void {
await project.addToProject(list);
should(project.files.filter(f => f.type === EntryType.File).length).equal(11); // txt file shouldn't be added to the project
should(project.files.filter(f => f.type === EntryType.Folder).length).equal(3); // 2folders + default Properties folder
should(project.files.filter(f => f.type === EntryType.Folder).length).equal(3); // 2folders + default Properties folder
});
it('Should throw error while adding Folder and Build entries to sqlproj when a file/folder does not exist on disk', async function (): Promise<void> {
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
const project = new Project(projFilePath);
await project.readProjFile();
let list: string[] = [];
let testFolderPath: string = await testUtils.createDummyFileStructure(true, list, path.dirname(projFilePath));
const nonexistentFile = path.join(testFolderPath, 'nonexistentFile.sql');
list.push(nonexistentFile);
await testUtils.shouldThrowSpecificError(async () => await project.addToProject(list), `ENOENT: no such file or directory, stat \'${nonexistentFile}\'`);
});
});