mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 17:22:42 -05:00
Aligns how Import and New project flows work (#11184)
* Slight import refactor * Test updates * Adds test, sets script name for File extractType to projectName * generating correct folder list * Correctly setting serverId for Imports started from Object Explorer * Adding regression test * uncommented test check
This commit is contained in:
@@ -26,8 +26,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
});
|
||||
|
||||
it('Should read Project from sqlproj', async function (): Promise<void> {
|
||||
const project: Project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project: Project = await Project.openProject(projFilePath);
|
||||
|
||||
// Files and folders
|
||||
should(project.files.filter(f => f.type === EntryType.File).length).equal(4);
|
||||
@@ -48,8 +47,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
});
|
||||
|
||||
it('Should add Folder and Build entries to sqlproj', async function (): Promise<void> {
|
||||
const project: Project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
const folderPath = 'Stored Procedures';
|
||||
const filePath = path.join(folderPath, 'Fake Stored Proc.sql');
|
||||
@@ -58,8 +56,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
await project.addFolderItem(folderPath);
|
||||
await project.addScriptItem(filePath, fileContents);
|
||||
|
||||
const newProject = new Project(projFilePath);
|
||||
await newProject.readProjFile();
|
||||
const newProject = await Project.openProject(projFilePath);
|
||||
|
||||
should(newProject.files.find(f => f.type === EntryType.Folder && f.relativePath === convertSlashesForSqlProj(folderPath))).not.equal(undefined);
|
||||
should(newProject.files.find(f => f.type === EntryType.File && f.relativePath === convertSlashesForSqlProj(filePath))).not.equal(undefined);
|
||||
@@ -71,8 +68,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
it('Should add Folder and Build entries to sqlproj with pre-existing scripts on disk', async function (): Promise<void> {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||
const project: Project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
let list: string[] = await testUtils.createListOfFiles(path.dirname(projFilePath));
|
||||
|
||||
@@ -84,8 +80,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
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();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
let list: string[] = [];
|
||||
let testFolderPath: string = await testUtils.createDummyFileStructure(true, list, path.dirname(projFilePath));
|
||||
@@ -98,8 +93,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
it('Should choose correct master dacpac', async function (): Promise<void> {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||
const project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
let uri = project.getSystemDacpacUri(constants.masterDacpac);
|
||||
let ssdtUri = project.getSystemDacpacSsdtUri(constants.masterDacpac);
|
||||
@@ -121,8 +115,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
it('Should choose correct msdb dacpac', async function (): Promise<void> {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||
const project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
let uri = project.getSystemDacpacUri(constants.msdbDacpac);
|
||||
let ssdtUri = project.getSystemDacpacSsdtUri(constants.msdbDacpac);
|
||||
@@ -144,8 +137,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
it('Should throw error when choosing correct master dacpac if invalid DSP', async function (): Promise<void> {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||
const project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
project.changeDSP('invalidPlatform');
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.getSystemDacpacUri(constants.masterDacpac), constants.invalidDataSchemaProvider);
|
||||
@@ -153,8 +145,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
it('Should add database references correctly', async function (): Promise<void> {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||
const project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
should(project.databaseReferences.length).equal(0, 'There should be no datbase references to start with');
|
||||
await project.addSystemDatabaseReference(SystemDatabase.master);
|
||||
@@ -178,8 +169,7 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
it('Should not allow adding duplicate database references', async function (): Promise<void> {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||
const project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
should(project.databaseReferences.length).equal(0, 'There should be no database references to start with');
|
||||
await project.addSystemDatabaseReference(SystemDatabase.master);
|
||||
@@ -220,8 +210,7 @@ describe('Project: round trip updates', function (): void {
|
||||
|
||||
async function testUpdateInRoundTrip(fileBeforeupdate: string, fileAfterUpdate: string, testTargets: boolean, testReferences: boolean): Promise<void> {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(fileBeforeupdate);
|
||||
const project: Project = new Project(projFilePath);
|
||||
await project.readProjFile();
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
if (testTargets) {
|
||||
await testUpdateTargetsImportsRoundTrip(project);
|
||||
|
||||
Reference in New Issue
Block a user