mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 17:22:51 -05:00
Hook up add database references dialog (#12002)
* initial dialog * got enabling working * add tests * cleanup * add test coverage for systemDbRadioButtonClick() * change DAC to .dacpac * remove isEmptyOrUndefined * hook up add database reference dialog * cleanup * Addressing comments
This commit is contained in:
@@ -192,23 +192,28 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
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);
|
||||
await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master });
|
||||
should(project.databaseReferences.length).equal(1, 'There should be one database reference after adding a reference to master');
|
||||
should(project.databaseReferences[0].databaseName).equal(constants.master, 'The database reference should be master');
|
||||
// make sure reference to SSDT master dacpac was added
|
||||
// make sure reference to ADS master dacpac and SSDT master dacpac was added
|
||||
let projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql(convertSlashesForSqlProj(project.getSystemDacpacUri(constants.master).fsPath.substring(1)));
|
||||
should(projFileText).containEql(convertSlashesForSqlProj(project.getSystemDacpacSsdtUri(constants.master).fsPath.substring(1)));
|
||||
|
||||
await project.addSystemDatabaseReference(SystemDatabase.msdb);
|
||||
await project.addSystemDatabaseReference({ databaseName: 'msdb', systemDb: SystemDatabase.msdb });
|
||||
should(project.databaseReferences.length).equal(2, 'There should be two database references after adding a reference to msdb');
|
||||
should(project.databaseReferences[1].databaseName).equal(constants.msdb, 'The database reference should be msdb');
|
||||
// make sure reference to SSDT msdb dacpac was added
|
||||
// make sure reference to ADS msdb dacpac and SSDT msdb dacpac was added
|
||||
projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql(convertSlashesForSqlProj(project.getSystemDacpacUri(constants.msdb).fsPath.substring(1)));
|
||||
should(projFileText).containEql(convertSlashesForSqlProj(project.getSystemDacpacSsdtUri(constants.msdb).fsPath.substring(1)));
|
||||
|
||||
await project.addDatabaseReference(Uri.parse('test.dacpac'), DatabaseReferenceLocation.sameDatabase);
|
||||
await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase });
|
||||
should(project.databaseReferences.length).equal(3, 'There should be three database references after adding a reference to test');
|
||||
should(project.databaseReferences[2].databaseName).equal('test', 'The database reference should be test');
|
||||
// make sure reference to test.dacpac was added
|
||||
projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql('test.dacpac');
|
||||
});
|
||||
|
||||
it('Should not allow adding duplicate database references', async function (): Promise<void> {
|
||||
@@ -216,20 +221,20 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
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);
|
||||
await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master });
|
||||
should(project.databaseReferences.length).equal(1, 'There should be one database reference after adding a reference to master');
|
||||
should(project.databaseReferences[0].databaseName).equal(constants.master, 'project.databaseReferences[0].databaseName should be master');
|
||||
|
||||
// try to add reference to master again
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addSystemDatabaseReference(SystemDatabase.master), constants.databaseReferenceAlreadyExists);
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master }), constants.databaseReferenceAlreadyExists);
|
||||
should(project.databaseReferences.length).equal(1, 'There should only be one database reference after trying to add a reference to master again');
|
||||
|
||||
await project.addDatabaseReference(Uri.parse('test.dacpac'), DatabaseReferenceLocation.sameDatabase);
|
||||
await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase });
|
||||
should(project.databaseReferences.length).equal(2, 'There should be two database references after adding a reference to test.dacpac');
|
||||
should(project.databaseReferences[1].databaseName).equal('test', 'project.databaseReferences[1].databaseName should be test');
|
||||
|
||||
// try to add reference to test.dacpac again
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addDatabaseReference(Uri.parse('test.dacpac'), DatabaseReferenceLocation.sameDatabase), constants.databaseReferenceAlreadyExists);
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase }), constants.databaseReferenceAlreadyExists);
|
||||
should(project.databaseReferences.length).equal(2, 'There should be two database references after trying to add a reference to test.dacpac again');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user