diff --git a/extensions/sql-database-projects/src/controllers/mainController.ts b/extensions/sql-database-projects/src/controllers/mainController.ts index 31546b2348..a9b018ce93 100644 --- a/extensions/sql-database-projects/src/controllers/mainController.ts +++ b/extensions/sql-database-projects/src/controllers/mainController.ts @@ -106,7 +106,7 @@ export default class MainController implements vscode.Disposable { isNewTable: false, tableScriptPath: filePath, projectFilePath: projectPath, - allScripts: project.files.filter(entry => entry.type === EntryType.File && path.extname(entry.fsUri.fsPath).toLowerCase() === constants.sqlFileExtension) + allScripts: project.sqlObjectScripts.filter(entry => entry.type === EntryType.File && path.extname(entry.fsUri.fsPath).toLowerCase() === constants.sqlFileExtension) .map(entry => entry.fsUri.fsPath), targetVersion: targetVersion }, { diff --git a/extensions/sql-database-projects/src/controllers/projectController.ts b/extensions/sql-database-projects/src/controllers/projectController.ts index ca743e1bca..7663125df7 100644 --- a/extensions/sql-database-projects/src/controllers/projectController.ts +++ b/extensions/sql-database-projects/src/controllers/projectController.ts @@ -1806,7 +1806,7 @@ export class ProjectsController { public async getProjectScriptFiles(projectFilePath: string): Promise { const project = await Project.openProject(projectFilePath); - return project.files + return project.sqlObjectScripts .filter(f => f.fsUri.fsPath.endsWith(constants.sqlFileExtension)) .map(f => f.fsUri.fsPath); } diff --git a/extensions/sql-database-projects/src/models/project.ts b/extensions/sql-database-projects/src/models/project.ts index f74790fa6c..8a477bfd07 100644 --- a/extensions/sql-database-projects/src/models/project.ts +++ b/extensions/sql-database-projects/src/models/project.ts @@ -42,7 +42,7 @@ export class Project implements ISqlProject { private _projectFilePath: string; private _projectFileName: string; private _projectGuid: string | undefined; - private _files: FileProjectEntry[] = []; + private _sqlObjectScripts: FileProjectEntry[] = []; private _folders: FileProjectEntry[] = []; private _dataSources: DataSource[] = []; private _databaseReferences: IDatabaseReferenceProjectEntry[] = []; @@ -83,8 +83,8 @@ export class Project implements ISqlProject { return this._projectGuid; } - public get files(): FileProjectEntry[] { - return this._files; + public get sqlObjectScripts(): FileProjectEntry[] { + return this._sqlObjectScripts; } public get folders(): FileProjectEntry[] { @@ -233,7 +233,7 @@ export class Project implements ISqlProject { await this.readNoneItems(); // also populates list of publish profiles, determined by file extension - await this.readFilesInProject(); // get SQL object scripts + await this.readSqlObjectScripts(); // get SQL object scripts await this.readFolders(); // get folders } @@ -297,7 +297,7 @@ export class Project implements ISqlProject { * Gets all the files specified by and removes all the files specified by * and all files included by the default glob of the folder of the sqlproj if it's an sdk style project */ - private async readFilesInProject(): Promise { + private async readSqlObjectScripts(): Promise { const filesSet: Set = new Set(); var result: GetScriptsResult = await this.sqlProjService.getSqlObjectScripts(this.projectFilePath); @@ -311,17 +311,17 @@ export class Project implements ISqlProject { } // create a FileProjectEntry for each file - const fileEntries: FileProjectEntry[] = []; + const sqlObjectScriptEntries: FileProjectEntry[] = []; for (let f of Array.from(filesSet.values())) { // read file to check if it has a "Create Table" statement const fullPath = path.join(utils.getPlatformSafeFileEntryPath(this.projectFolderPath), utils.getPlatformSafeFileEntryPath(f)); const containsCreateTableStatement: boolean = await utils.fileContainsCreateTableStatement(fullPath, this.getProjectTargetVersion()); - fileEntries.push(this.createFileProjectEntry(f, EntryType.File, undefined, containsCreateTableStatement)); + sqlObjectScriptEntries.push(this.createFileProjectEntry(f, EntryType.File, undefined, containsCreateTableStatement)); } - this._files = fileEntries; + this._sqlObjectScripts = sqlObjectScriptEntries; } private async readFolders(): Promise { @@ -479,7 +479,7 @@ export class Project implements ISqlProject { //#endregion private resetProject(): void { - this._files = []; + this._sqlObjectScripts = []; this._databaseReferences = []; this._sqlCmdVariables = new Map(); this._preDeployScripts = []; @@ -541,7 +541,7 @@ export class Project implements ISqlProject { const result = await this.sqlProjService.deleteFolder(this.projectFilePath, relativeFolderPath); this.throwIfFailed(result); - await this.readFilesInProject(); + await this.readSqlObjectScripts(); await this.readPreDeployScripts(); await this.readPostDeployScripts(); await this.readNoneItems(); @@ -552,7 +552,7 @@ export class Project implements ISqlProject { const result = await this.sqlProjService.excludeFolder(this.projectFilePath, relativeFolderPath); this.throwIfFailed(result); - await this.readFilesInProject(); + await this.readSqlObjectScripts(); await this.readPreDeployScripts(); await this.readPostDeployScripts(); await this.readNoneItems(); @@ -563,7 +563,7 @@ export class Project implements ISqlProject { const result = await this.sqlProjService.moveFolder(this.projectFilePath, relativeSourcePath, relativeDestinationPath); this.throwIfFailed(result); - await this.readFilesInProject(); + await this.readSqlObjectScripts(); await this.readPreDeployScripts(); await this.readPostDeployScripts(); await this.readNoneItems(); @@ -579,7 +579,7 @@ export class Project implements ISqlProject { this.throwIfFailed(result); if (reloadAfter) { - await this.readFilesInProject(); + await this.readSqlObjectScripts(); await this.readFolders(); } } @@ -589,7 +589,7 @@ export class Project implements ISqlProject { await this.addSqlObjectScript(path, false /* reloadAfter */); } - await this.readFilesInProject(); + await this.readSqlObjectScripts(); await this.readFolders(); } @@ -597,7 +597,7 @@ export class Project implements ISqlProject { const result = await this.sqlProjService.deleteSqlObjectScript(this.projectFilePath, relativePath); this.throwIfFailed(result); - await this.readFilesInProject(); + await this.readSqlObjectScripts(); await this.readFolders(); } @@ -605,7 +605,7 @@ export class Project implements ISqlProject { const result = await this.sqlProjService.excludeSqlObjectScript(this.projectFilePath, relativePath); this.throwIfFailed(result); - await this.readFilesInProject(); + await this.readSqlObjectScripts(); await this.readFolders(); } @@ -718,7 +718,7 @@ export class Project implements ISqlProject { // Check if file already has been added to sqlproj const normalizedRelativeFilePath = utils.convertSlashesForSqlProj(relativeFilePath); - const existingEntry = this.files.find(f => f.relativePath.toUpperCase() === normalizedRelativeFilePath.toUpperCase()); + const existingEntry = this.sqlObjectScripts.find(f => f.relativePath.toUpperCase() === normalizedRelativeFilePath.toUpperCase()); if (existingEntry) { return existingEntry; } @@ -758,7 +758,7 @@ export class Project implements ISqlProject { if (path.extname(filePath) === constants.sqlFileExtension) { result = await this.sqlProjService.addSqlObjectScript(this.projectFilePath, normalizedRelativeFilePath) - await this.readFilesInProject(); + await this.readSqlObjectScripts(); } else { result = await this.sqlProjService.addNoneItem(this.projectFilePath, normalizedRelativeFilePath); await this.readNoneItems(); diff --git a/extensions/sql-database-projects/src/models/tree/projectTreeItem.ts b/extensions/sql-database-projects/src/models/tree/projectTreeItem.ts index c62f893f39..4da4ab4a4f 100644 --- a/extensions/sql-database-projects/src/models/tree/projectTreeItem.ts +++ b/extensions/sql-database-projects/src/models/tree/projectTreeItem.ts @@ -106,7 +106,7 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem { } // sql object scripts - for (const entry of this.project.files) { + for (const entry of this.project.sqlObjectScripts) { let newNode: fileTree.FileNode; if (entry.sqlObjectType === ExternalStreamingJob) { diff --git a/extensions/sql-database-projects/src/sqldbproj.d.ts b/extensions/sql-database-projects/src/sqldbproj.d.ts index 39d408db7f..c6a0433699 100644 --- a/extensions/sql-database-projects/src/sqldbproj.d.ts +++ b/extensions/sql-database-projects/src/sqldbproj.d.ts @@ -246,9 +246,9 @@ declare module 'sqldbproj' { readonly projectFileName: string; /** - * Files and folders that are included in the project + * SQL object scripts in this project */ - readonly files: IFileProjectEntry[]; + readonly sqlObjectScripts: IFileProjectEntry[]; /** * SqlCmd variables and their values diff --git a/extensions/sql-database-projects/src/test/project.test.ts b/extensions/sql-database-projects/src/test/project.test.ts index e2c2cf0f96..87276f7702 100644 --- a/extensions/sql-database-projects/src/test/project.test.ts +++ b/extensions/sql-database-projects/src/test/project.test.ts @@ -33,7 +33,7 @@ describe('Project: sqlproj content operations', function (): void { const project: Project = await Project.openProject(projFilePath); // Files and folders - (project.files.map(f => f.relativePath)).should.deepEqual([ + (project.sqlObjectScripts.map(f => f.relativePath)).should.deepEqual([ '..\\Test\\Test.sql', 'MyExternalStreamingJob.sql', 'Tables\\Action History.sql', @@ -118,18 +118,18 @@ describe('Project: sqlproj content operations', function (): void { const scriptContentsTagged = 'EXEC sys.sp_create_streaming_job \'job\', \'SELECT 7\''; (project.folders.length).should.equal(0); - (project.files.length).should.equal(0); + (project.sqlObjectScripts.length).should.equal(0); await project.addFolder(folderPath); await project.addScriptItem(scriptPath, scriptContents); await project.addScriptItem(scriptPathTagged, scriptContentsTagged, ItemType.externalStreamingJob); (project.folders.length).should.equal(1); - (project.files.length).should.equal(2); + (project.sqlObjectScripts.length).should.equal(2); should(project.folders.find(f => f.relativePath === convertSlashesForSqlProj(folderPath))).not.equal(undefined); - should(project.files.find(f => f.relativePath === convertSlashesForSqlProj(scriptPath))).not.equal(undefined); - should(project.files.find(f => f.relativePath === convertSlashesForSqlProj(scriptPathTagged))).not.equal(undefined); + should(project.sqlObjectScripts.find(f => f.relativePath === convertSlashesForSqlProj(scriptPath))).not.equal(undefined); + should(project.sqlObjectScripts.find(f => f.relativePath === convertSlashesForSqlProj(scriptPathTagged))).not.equal(undefined); // TODO: support for tagged entries not supported in DacFx.Projects //should(project.files.find(f => f.relativePath === convertSlashesForSqlProj(scriptPathTagged))?.sqlObjectType).equal(constants.ExternalStreamingJob); }); @@ -138,7 +138,7 @@ describe('Project: sqlproj content operations', function (): void { const project = await testUtils.createTestSqlProject(this.test); // initial setup - (project.files.length).should.equal(0, 'initial number of scripts'); + (project.sqlObjectScripts.length).should.equal(0, 'initial number of scripts'); // create files on disk const tablePath = path.join(project.projectFolderPath, 'MyTable.sql'); @@ -151,7 +151,7 @@ describe('Project: sqlproj content operations', function (): void { await project.addSqlObjectScripts(['MyTable.sql', 'MyView.sql']); // verify result - (project.files.length).should.equal(2, 'Number of scripts after adding'); + (project.sqlObjectScripts.length).should.equal(2, 'Number of scripts after adding'); }); // TODO: move to DacFx once script contents supported @@ -261,7 +261,7 @@ describe('Project: sqlproj content operations', function (): void { // Try adding project root folder itself - this is silently ignored await project.addFolder(path.dirname(projFilePath)); - should.equal(project.files.length, 0, 'Nothing should be added to the project'); + should.equal(project.sqlObjectScripts.length, 0, 'Nothing should be added to the project'); // Try adding a parent of the project folder await testUtils.shouldThrowSpecificError( @@ -288,8 +288,8 @@ describe('Project: sqlproj content operations', function (): void { await project.addExistingItem(txtFile); // Validate files should have been added to project - (project.files.length).should.equal(1, `SQL script object count: ${project.files.map(x => x.relativePath).join('; ')}`); - (project.files[0].relativePath).should.equal('test.sql'); + (project.sqlObjectScripts.length).should.equal(1, `SQL script object count: ${project.sqlObjectScripts.map(x => x.relativePath).join('; ')}`); + (project.sqlObjectScripts[0].relativePath).should.equal('test.sql'); should(project.folders.length).equal(1, 'folders'); (project.folders[0].relativePath).should.equal('foo'); @@ -336,7 +336,7 @@ describe('Project: sdk style project content operations', function (): void { should(project.preDeployScripts.length).equal(1, 'Script.PreDeployment1.sql should have been added'); should(project.noneDeployScripts.length).equal(1, 'Script.PreDeployment2.sql should have been added'); should(project.preDeployScripts.length).equal(1, 'Script.PostDeployment1.sql should have been added'); - should(project.files.length).equal(0, 'There should not be any SQL object scripts'); + should(project.sqlObjectScripts.length).equal(0, 'There should not be any SQL object scripts'); // exclude the pre/post/none deploy script await project.excludePreDeploymentScript('Script.PreDeployment1.sql'); @@ -346,7 +346,7 @@ describe('Project: sdk style project content operations', function (): void { should(project.preDeployScripts.length).equal(0, 'Script.PreDeployment1.sql should have been removed'); should(project.noneDeployScripts.length).equal(0, 'Script.PreDeployment2.sql should have been removed'); should(project.postDeployScripts.length).equal(0, 'Script.PostDeployment1.sql should have been removed'); - should(project.files.length).equal(0, 'There should not be any SQL object scripts after the excludes'); + should(project.sqlObjectScripts.length).equal(0, 'There should not be any SQL object scripts after the excludes'); }); it('Should handle excluding glob included folders', async function (): Promise { @@ -356,7 +356,7 @@ describe('Project: sdk style project content operations', function (): void { const project: Project = await Project.openProject(projFilePath); - should(project.files.length).equal(13); + should(project.sqlObjectScripts.length).equal(13); should(project.folders.length).equal(3); should(project.noneDeployScripts.length).equal(2); @@ -365,7 +365,7 @@ describe('Project: sdk style project content operations', function (): void { // verify folder and contents are excluded should(project.folders.length).equal(1); - should(project.files.length).equal(6); + should(project.sqlObjectScripts.length).equal(6); should(project.noneDeployScripts.length).equal(1, 'Script.PostDeployment2.sql should have been excluded'); should(project.folders.find(f => f.relativePath === 'folder1')).equal(undefined); }); @@ -377,7 +377,7 @@ describe('Project: sdk style project content operations', function (): void { const project: Project = await Project.openProject(projFilePath); - should(project.files.length).equal(13); + should(project.sqlObjectScripts.length).equal(13); should(project.folders.length).equal(3); // try to exclude a glob included folder @@ -385,7 +385,7 @@ describe('Project: sdk style project content operations', function (): void { // verify folder and contents are excluded should(project.folders.length).equal(2); - should(project.files.length).equal(11); + should(project.sqlObjectScripts.length).equal(11); should(project.folders.find(f => f.relativePath === 'folder1\\nestedFolder')).equal(undefined); }); @@ -397,7 +397,7 @@ describe('Project: sdk style project content operations', function (): void { const project: Project = await Project.openProject(projFilePath); - should(project.files.length).equal(11); + should(project.sqlObjectScripts.length).equal(11); should(project.folders.length).equal(2); should(project.folders.find(f => f.relativePath === 'folder1')!).not.equal(undefined); should(project.folders.find(f => f.relativePath === 'folder2')!).not.equal(undefined); @@ -407,7 +407,7 @@ describe('Project: sdk style project content operations', function (): void { // verify folder and contents are excluded should(project.folders.length).equal(1); - should(project.files.length).equal(6); + should(project.sqlObjectScripts.length).equal(6); should(project.folders.find(f => f.relativePath === 'folder1')).equal(undefined); // try to exclude an explicitly included folder with trailing \ in sqlproj @@ -415,7 +415,7 @@ describe('Project: sdk style project content operations', function (): void { // verify folder and contents are excluded should(project.folders.length).equal(0); - should(project.files.length).equal(1); + should(project.sqlObjectScripts.length).equal(1); should(project.folders.find(f => f.relativePath === 'folder2')).equal(undefined); }); @@ -426,7 +426,7 @@ describe('Project: sdk style project content operations', function (): void { const project: Project = await Project.openProject(projFilePath); - should(project.files.length).equal(13); + should(project.sqlObjectScripts.length).equal(13); should(project.folders.length).equal(3); should(project.folders.find(f => f.relativePath === 'folder1')!).not.equal(undefined); should(project.folders.find(f => f.relativePath === 'folder2')!).not.equal(undefined); @@ -436,7 +436,7 @@ describe('Project: sdk style project content operations', function (): void { // verify the project not longer has folder2 and its contents should(project.folders.length).equal(2); - should(project.files.length).equal(8); + should(project.sqlObjectScripts.length).equal(8); should(project.folders.find(f => f.relativePath === 'folder2')).equal(undefined); // try to delete an explicitly included folder without trailing \ in sqlproj @@ -444,7 +444,7 @@ describe('Project: sdk style project content operations', function (): void { // verify the project not longer has folder1 and its contents should(project.folders.length).equal(0); - should(project.files.length).equal(1); + should(project.sqlObjectScripts.length).equal(1); should(project.folders.find(f => f.relativePath === 'folder1')).equal(undefined); }); diff --git a/extensions/sql-database-projects/src/test/projectController.test.ts b/extensions/sql-database-projects/src/test/projectController.test.ts index 7f83217abb..15cf1ce79d 100644 --- a/extensions/sql-database-projects/src/test/projectController.test.ts +++ b/extensions/sql-database-projects/src/test/projectController.test.ts @@ -87,7 +87,7 @@ describe('ProjectsController', function (): void { }); const project = await Project.openProject(projFilePath); - should(project.files.length).equal(7, `The 7 template files for an edge project should be present. Actual: ${project.files.length}`); + should(project.sqlObjectScripts.length).equal(7, `The 7 template files for an edge project should be present. Actual: ${project.sqlObjectScripts.length}`); }); it('Should return silently when no SQL object name provided in prompts', async function (): Promise { @@ -98,9 +98,9 @@ describe('ProjectsController', function (): void { const projController = new ProjectsController(testContext.outputChannel); const project = new Project('FakePath'); - should(project.files.length).equal(0); + should(project.sqlObjectScripts.length).equal(0); await projController.addItemPrompt(new Project('FakePath'), '', { itemType: ItemType.script }); - should(project.files.length).equal(0, 'Expected to return without throwing an exception or adding a file when an empty/undefined name is provided.'); + should(project.sqlObjectScripts.length).equal(0, 'Expected to return without throwing an exception or adding a file when an empty/undefined name is provided.'); should(showErrorMessageSpy.notCalled).be.true('showErrorMessage should not have been called'); sinon.restore(); } @@ -114,10 +114,10 @@ describe('ProjectsController', function (): void { const projController = new ProjectsController(testContext.outputChannel); let project = await testUtils.createTestProject(this.test, baselines.newProjectFileBaseline); - should(project.files.length).equal(0, 'There should be no files'); + should(project.sqlObjectScripts.length).equal(0, 'There should be no files'); await projController.addItemPrompt(project, '', { itemType: ItemType.script }); - should(project.files.length).equal(1, 'File should be successfully added'); + should(project.sqlObjectScripts.length).equal(1, 'File should be successfully added'); await projController.addItemPrompt(project, '', { itemType: ItemType.script }); const msg = constants.fileAlreadyExists(tableName); should(spy.calledOnce).be.true('showErrorMessage should have been called exactly once'); @@ -130,9 +130,9 @@ describe('ProjectsController', function (): void { const projController = new ProjectsController(testContext.outputChannel); const project = await testUtils.createTestProject(this.test, baselines.newProjectFileBaseline); - should(project.files.length).equal(0, 'There should be no files'); + should(project.sqlObjectScripts.length).equal(0, 'There should be no files'); await projController.addItemPrompt(project, ''); - should(project.files.length).equal(0, 'File should not have been added'); + should(project.sqlObjectScripts.length).equal(0, 'File should not have been added'); should(spy.called).be.false(`showErrorMessage should not have been called called. Actual '${spy.getCall(0)?.args[0]}'`); }); @@ -144,9 +144,9 @@ describe('ProjectsController', function (): void { const projController = new ProjectsController(testContext.outputChannel); let project = await testUtils.createTestProject(this.test, baselines.newProjectFileBaseline); - should(project.files.length).equal(0, 'There should be no files'); + should(project.sqlObjectScripts.length).equal(0, 'There should be no files'); await projController.addItemPrompt(project, '', { itemType: ItemType.script }); - should(project.files.length).equal(1, 'File should be successfully added'); + should(project.sqlObjectScripts.length).equal(1, 'File should be successfully added'); // exclude item const projTreeRoot = new ProjectRootTreeItem(project); @@ -154,7 +154,7 @@ describe('ProjectsController', function (): void { // reload project project = await Project.openProject(project.projectFilePath); - should(project.files.length).equal(0, 'File should be successfully excluded'); + should(project.sqlObjectScripts.length).equal(0, 'File should be successfully excluded'); should(spy.called).be.false(`showErrorMessage not called with expected message. Actual '${spy.getCall(0)?.args[0]}'`); // add item back @@ -163,7 +163,7 @@ describe('ProjectsController', function (): void { // reload project project = await Project.openProject(project.projectFilePath); - should(project.files.length).equal(1, 'File should be successfully re-added'); + should(project.sqlObjectScripts.length).equal(1, 'File should be successfully re-added'); }); it('Should show error if trying to add a folder that already exists', async function (): Promise { @@ -219,7 +219,7 @@ describe('ProjectsController', function (): void { // reload project project = await Project.openProject(project.projectFilePath); - should(project.folders.length).equal(beforeFolderCount + 1, `Folder count should be increased by one after adding the folder ${folderName}. before folders: ${JSON.stringify(beforeFolders)}/n after folders: ${JSON.stringify(project.files.map(f => f.relativePath))}`); + should(project.folders.length).equal(beforeFolderCount + 1, `Folder count should be increased by one after adding the folder ${folderName}. before folders: ${JSON.stringify(beforeFolders)}/n after folders: ${JSON.stringify(project.sqlObjectScripts.map(f => f.relativePath))}`); sinon.restore(); } @@ -254,7 +254,7 @@ describe('ProjectsController', function (): void { proj = await Project.openProject(proj.projectFilePath); // reload edited sqlproj from disk // confirm result - should(proj.files.length).equal(3, 'number of file entries'); // lowerEntry and the contained scripts should be deleted + should(proj.sqlObjectScripts.length).equal(3, 'number of file entries'); // lowerEntry and the contained scripts should be deleted should(proj.folders[0].relativePath).equal('UpperFolder'); should(proj.preDeployScripts.length).equal(0, 'Pre Deployment scripts should have been deleted'); should(proj.postDeployScripts.length).equal(0, 'Post Deployment scripts should have been deleted'); @@ -318,7 +318,7 @@ describe('ProjectsController', function (): void { proj = await Project.openProject(proj.projectFilePath); // reload edited sqlproj from disk // confirm result - should(proj.files.length).equal(0, 'number of file entries'); // LowerFolder and the contained scripts should be excluded + should(proj.sqlObjectScripts.length).equal(0, 'number of file entries'); // LowerFolder and the contained scripts should be excluded should(proj.folders.find(f => f.relativePath === 'UpperFolder')).not.equal(undefined, 'UpperFolder should still be there'); should(proj.preDeployScripts.length).equal(0, 'Pre deployment scripts'); should(proj.postDeployScripts.length).equal(0, 'Post deployment scripts'); @@ -338,7 +338,7 @@ describe('ProjectsController', function (): void { const projTreeRoot = new ProjectRootTreeItem(proj); should(await utils.exists(path.join(proj.projectFolderPath, 'SomeFolder\\MyTable.sql'))).be.true('File should exist in original location'); - (proj.files.length).should.equal(1, 'Starting number of files'); + (proj.sqlObjectScripts.length).should.equal(1, 'Starting number of scripts'); (proj.folders.length).should.equal(1, 'Starting number of folders'); // exclude folder @@ -349,7 +349,7 @@ describe('ProjectsController', function (): void { proj = await Project.openProject(proj.projectFilePath); should(await utils.exists(path.join(proj.projectFolderPath, 'SomeFolder\\MyTable.sql'))).be.true('File should still exist on disk'); - (proj.files.length).should.equal(0, 'Number of files should not have changed'); + (proj.sqlObjectScripts.length).should.equal(0, 'Number of scripts should not have changed'); (proj.folders.length).should.equal(0, 'Number of folders should not have changed'); }); @@ -375,7 +375,7 @@ describe('ProjectsController', function (): void { proj = await Project.openProject(proj.projectFilePath); // Confirm result - should(proj.files.some(x => x.relativePath === 'UpperFolder')).equal(false, 'UpperFolder should not be part of proj file any more'); + should(proj.sqlObjectScripts.some(x => x.relativePath === 'UpperFolder')).equal(false, 'UpperFolder should not be part of proj file any more'); should(await utils.exists(scriptEntry.fsUri.fsPath)).equal(false, 'script is supposed to be deleted from disk'); should(await utils.exists(lowerFolder.relativeProjectUri.fsPath)).equal(false, 'LowerFolder is supposed to be deleted from disk'); should(await utils.exists(upperFolder.relativeProjectUri.fsPath)).equal(false, 'UpperFolder is supposed to be deleted from disk'); @@ -392,7 +392,7 @@ describe('ProjectsController', function (): void { // change the sql project file await fs.writeFile(sqlProjPath, baselines.newProjectFileWithScriptBaseline); - should(project.files.length).equal(0); + should(project.sqlObjectScripts.length).equal(0); // call reload project const projTreeRoot = new ProjectRootTreeItem(project); @@ -404,7 +404,7 @@ describe('ProjectsController', function (): void { treeProvider.load([project]); // check that the new project is in the tree - should(project.files.length).equal(1); + should(project.sqlObjectScripts.length).equal(1); should(treeProvider.getChildren()[0].children.find(c => c.friendlyName === 'Script1.sql')).not.equal(undefined); }); @@ -419,7 +419,7 @@ describe('ProjectsController', function (): void { sinon.stub(utils, 'sanitizeStringForFilename').returns(preDeployScriptName); should(project.preDeployScripts.length).equal(0, 'There should be no pre deploy scripts'); await projController.addItemPrompt(project, '', { itemType: ItemType.preDeployScript }); - should(project.preDeployScripts.length).equal(1, `Pre deploy script should be successfully added. ${project.preDeployScripts.length}, ${project.files.length}`); + should(project.preDeployScripts.length).equal(1, `Pre deploy script should be successfully added. ${project.preDeployScripts.length}, ${project.sqlObjectScripts.length}`); sinon.restore(); sinon.stub(vscode.window, 'showInputBox').resolves(postDeployScriptName); @@ -835,10 +835,10 @@ describe('ProjectsController', function (): void { should(actual).equal(constants.autorestPostDeploymentScriptName, `Unexpected post-deployment script name: ${actual}, expected ${constants.autorestPostDeploymentScriptName}`); const expectedScripts = fileList.filter(f => path.extname(f.fsPath) === '.sql'); - should(project.files.filter(f => f.type === EntryType.File).length).equal(expectedScripts.length, 'Unexpected number of scripts in project'); + should(project.sqlObjectScripts.filter(f => f.type === EntryType.File).length).equal(expectedScripts.length, 'Unexpected number of scripts in project'); const expectedFolders = fileList.filter(f => path.extname(f.fsPath) === '' && f.fsPath.toUpperCase() !== newProjFolder.toUpperCase()); - should(project.files.filter(f => f.type === EntryType.Folder).length).equal(expectedFolders.length, 'Unexpected number of folders in project'); + should(project.sqlObjectScripts.filter(f => f.type === EntryType.Folder).length).equal(expectedFolders.length, 'Unexpected number of folders in project'); }); }); @@ -862,7 +862,7 @@ describe('ProjectsController', function (): void { // reload project and verify file was moved proj = await Project.openProject(proj.projectFilePath); - should(proj.files.find(f => f.relativePath === 'UpperFolder\\script1.sql') !== undefined).be.true('The file path should have been updated'); + should(proj.sqlObjectScripts.find(f => f.relativePath === 'UpperFolder\\script1.sql') !== undefined).be.true('The file path should have been updated'); should(await utils.exists(path.join(proj.projectFolderPath, 'UpperFolder', 'script1.sql'))).be.true('The moved file should exist'); }); @@ -884,7 +884,7 @@ describe('ProjectsController', function (): void { // reload project and verify file was not moved proj = await Project.openProject(proj.projectFilePath); - should(proj.files.find(f => f.relativePath === 'script1.sql') !== undefined).be.true(`The file path should not have been updated when trying to move script1.sql to ${folder}`); + should(proj.sqlObjectScripts.find(f => f.relativePath === 'script1.sql') !== undefined).be.true(`The file path should not have been updated when trying to move script1.sql to ${folder}`); should(spy.notCalled).be.true('showErrorMessage should not have been called.'); spy.restore(); } @@ -943,7 +943,7 @@ describe('ProjectsController', function (): void { // verify script1.sql was not moved proj1 = await Project.openProject(proj1.projectFilePath); - should(proj1.files.find(f => f.relativePath === 'script1.sql') !== undefined).be.true(`The file path should not have been updated when trying to move script1.sql to proj2`); + should(proj1.sqlObjectScripts.find(f => f.relativePath === 'script1.sql') !== undefined).be.true(`The file path should not have been updated when trying to move script1.sql to proj2`); }); }); @@ -960,7 +960,7 @@ describe('ProjectsController', function (): void { // reload project and verify file was not renamed proj = await Project.openProject(proj.projectFilePath); - should(proj.files.find(f => f.relativePath === 'script1.sql') !== undefined).be.true('The file path should not have been updated'); + should(proj.sqlObjectScripts.find(f => f.relativePath === 'script1.sql') !== undefined).be.true('The file path should not have been updated'); should(await utils.exists(path.join(proj.projectFolderPath, 'script1.sql'))).be.true('The moved file should exist'); }); @@ -976,7 +976,7 @@ describe('ProjectsController', function (): void { // reload project and verify file was renamed proj = await Project.openProject(proj.projectFilePath); - should(proj.files.find(f => f.relativePath === 'newName.sql') !== undefined).be.true('The file path should have been updated'); + should(proj.sqlObjectScripts.find(f => f.relativePath === 'newName.sql') !== undefined).be.true('The file path should have been updated'); should(await utils.exists(path.join(proj.projectFolderPath, 'newName.sql'))).be.true('The moved file should exist'); }); @@ -1016,7 +1016,7 @@ describe('ProjectsController', function (): void { sinon.stub(vscode.window, 'showInputBox').resolves('RenamedFolder'); should(await utils.exists(path.join(proj.projectFolderPath, 'SomeFolder\\MyTable.sql'))).be.true('File should exist in original location'); - (proj.files.length).should.equal(1, 'Starting number of files'); + (proj.sqlObjectScripts.length).should.equal(1, 'Starting number of scripts'); (proj.folders.length).should.equal(1, 'Starting number of folders'); // rename folder @@ -1027,10 +1027,10 @@ describe('ProjectsController', function (): void { proj = await Project.openProject(proj.projectFilePath); should(await utils.exists(path.join(proj.projectFolderPath, 'RenamedFolder\\MyTable.sql'))).be.true('File should exist in new location'); - (proj.files.length).should.equal(1, 'Number of files should not have changed'); + (proj.sqlObjectScripts.length).should.equal(1, 'Number of scripts should not have changed'); (proj.folders.length).should.equal(1, 'Number of folders should not have changed'); should(proj.folders.find(f => f.relativePath === 'RenamedFolder') !== undefined).be.true('The folder path should have been updated'); - should(proj.files.find(f => f.relativePath === 'RenamedFolder\\MyTable.sql') !== undefined).be.true('Path of the script in the folder should have been updated'); + should(proj.sqlObjectScripts.find(f => f.relativePath === 'RenamedFolder\\MyTable.sql') !== undefined).be.true('Path of the script in the folder should have been updated'); }); }); @@ -1137,7 +1137,7 @@ async function setupDeleteExcludeTest(proj: Project): Promise<[FileProjectEntry, sinon.stub(vscode.window, 'showWarningMessage').returns(Promise.resolve(constants.yesString)); // confirm setup - should(proj.files.length).equal(3, 'number of file entries'); + should(proj.sqlObjectScripts.length).equal(3, 'number of file entries'); should(proj.folders.length).equal(2, 'number of folder entries'); should(proj.preDeployScripts.length).equal(1, 'number of pre-deployment script entries'); should(proj.postDeployScripts.length).equal(1, 'number of post-deployment script entries'); diff --git a/extensions/sql-database-projects/src/test/projectTree.test.ts b/extensions/sql-database-projects/src/test/projectTree.test.ts index b9c6a00c0a..078f6308c8 100644 --- a/extensions/sql-database-projects/src/test/projectTree.test.ts +++ b/extensions/sql-database-projects/src/test/projectTree.test.ts @@ -53,15 +53,15 @@ describe('Project Tree tests', function (): void { // nested entries before explicit top-level folder entry // also, ordering of files/folders at all levels - proj.files.push(proj.createFileProjectEntry(path.join('someFolder', 'bNestedTest.sql'), EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry(path.join('someFolder', 'bNestedTest.sql'), EntryType.File)); proj.folders.push(proj.createFileProjectEntry(path.join('someFolder', 'bNestedFolder'), EntryType.Folder)); - proj.files.push(proj.createFileProjectEntry(path.join('someFolder', 'aNestedTest.sql'), EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry(path.join('someFolder', 'aNestedTest.sql'), EntryType.File)); proj.folders.push(proj.createFileProjectEntry(path.join('someFolder', 'aNestedFolder'), EntryType.Folder)); proj.folders.push(proj.createFileProjectEntry('someFolder', EntryType.Folder)); // duplicate files - proj.files.push(proj.createFileProjectEntry('duplicate.sql', EntryType.File)); - proj.files.push(proj.createFileProjectEntry('duplicate.sql', EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry('duplicate.sql', EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry('duplicate.sql', EntryType.File)); // duplicate folders proj.folders.push(proj.createFileProjectEntry('duplicateFolder', EntryType.Folder)); @@ -101,11 +101,11 @@ describe('Project Tree tests', function (): void { // nested entries before explicit top-level folder entry // also, ordering of files/folders at all levels - proj.files.push(proj.createFileProjectEntry('someFolder1\\MyNestedFolder1\\MyFile1.sql', EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry('someFolder1\\MyNestedFolder1\\MyFile1.sql', EntryType.File)); proj.folders.push(proj.createFileProjectEntry('someFolder1\\MyNestedFolder2', EntryType.Folder)); proj.folders.push(proj.createFileProjectEntry('someFolder1', EntryType.Folder)); proj.folders.push(proj.createFileProjectEntry('someFolder1\\MyNestedFolder1', EntryType.Folder)); - proj.files.push(proj.createFileProjectEntry('someFolder1\\MyFile2.sql', EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry('someFolder1\\MyFile2.sql', EntryType.File)); const tree = new ProjectRootTreeItem(proj); should(tree.children.map(x => x.relativeProjectUri.path)).deepEqual([ @@ -125,9 +125,9 @@ describe('Project Tree tests', function (): void { // nested entries before explicit top-level folder entry // also, ordering of files/folders at all levels - proj.files.push(proj.createFileProjectEntry('..\\someFolder1\\MyNestedFolder1\\MyFile1.sql', EntryType.File)); - proj.files.push(proj.createFileProjectEntry('..\\..\\someFolder2\\MyFile2.sql', EntryType.File)); - proj.files.push(proj.createFileProjectEntry('..\\..\\someFolder3', EntryType.Folder)); // folder should not be counted (same as SSDT) + proj.sqlObjectScripts.push(proj.createFileProjectEntry('..\\someFolder1\\MyNestedFolder1\\MyFile1.sql', EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry('..\\..\\someFolder2\\MyFile2.sql', EntryType.File)); + proj.sqlObjectScripts.push(proj.createFileProjectEntry('..\\..\\someFolder3', EntryType.Folder)); // folder should not be counted (same as SSDT) const tree = new ProjectRootTreeItem(proj); should(tree.children.map(x => x.relativeProjectUri.path)).deepEqual([