mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 09:35:36 -05:00
Read publish profile using DacFX (#16110)
* Read publish profile using DacFX in VS Code * Fixes * complete promise on hide * comment
This commit is contained in:
@@ -15,6 +15,7 @@ import * as templates from '../templates/templates';
|
||||
import * as testUtils from './testUtils';
|
||||
import * as constants from '../common/constants';
|
||||
import * as mssql from '../../../mssql';
|
||||
import * as utils from '../common/utils';
|
||||
|
||||
import { SqlDatabaseProjectTreeViewProvider } from '../controllers/databaseProjectTreeViewProvider';
|
||||
import { ProjectsController } from '../controllers/projectController';
|
||||
@@ -23,7 +24,6 @@ import { createContext, TestContext, mockDacFxResult, mockConnectionProfile } fr
|
||||
import { Project, reservedProjectFolders, SystemDatabase, FileProjectEntry, SystemDatabaseReferenceProjectEntry } from '../models/project';
|
||||
import { PublishDatabaseDialog } from '../dialogs/publishDatabaseDialog';
|
||||
import { IPublishSettings, IGenerateScriptSettings } from '../models/IPublishSettings';
|
||||
import { exists } from '../common/utils';
|
||||
import { ProjectRootTreeItem } from '../models/tree/projectTreeItem';
|
||||
import { FolderNode, FileNode } from '../models/tree/fileFolderTreeItem';
|
||||
import { BaseProjectTreeItem } from '../models/tree/baseTreeItem';
|
||||
@@ -198,10 +198,10 @@ describe('ProjectsController', function (): void {
|
||||
should(proj.postDeployScripts.length).equal(0);
|
||||
should(proj.noneDeployScripts.length).equal(0);
|
||||
|
||||
should(await exists(scriptEntry.fsUri.fsPath)).equal(false, 'script is supposed to be deleted');
|
||||
should(await exists(preDeployEntry.fsUri.fsPath)).equal(false, 'pre-deployment script is supposed to be deleted');
|
||||
should(await exists(postDeployEntry.fsUri.fsPath)).equal(false, 'post-deployment script is supposed to be deleted');
|
||||
should(await exists(noneEntry.fsUri.fsPath)).equal(false, 'none entry pre-deployment script is supposed to be deleted');
|
||||
should(await utils.exists(scriptEntry.fsUri.fsPath)).equal(false, 'script is supposed to be deleted');
|
||||
should(await utils.exists(preDeployEntry.fsUri.fsPath)).equal(false, 'pre-deployment script is supposed to be deleted');
|
||||
should(await utils.exists(postDeployEntry.fsUri.fsPath)).equal(false, 'post-deployment script is supposed to be deleted');
|
||||
should(await utils.exists(noneEntry.fsUri.fsPath)).equal(false, 'none entry pre-deployment script is supposed to be deleted');
|
||||
});
|
||||
|
||||
it('Should delete database references', async function (): Promise<void> {
|
||||
@@ -259,10 +259,10 @@ describe('ProjectsController', function (): void {
|
||||
should(proj.postDeployScripts.length).equal(0);
|
||||
should(proj.noneDeployScripts.length).equal(0);
|
||||
|
||||
should(await exists(scriptEntry.fsUri.fsPath)).equal(true, 'script is supposed to still exist on disk');
|
||||
should(await exists(preDeployEntry.fsUri.fsPath)).equal(true, 'pre-deployment script is supposed to still exist on disk');
|
||||
should(await exists(postDeployEntry.fsUri.fsPath)).equal(true, 'post-deployment script is supposed to still exist on disk');
|
||||
should(await exists(noneEntry.fsUri.fsPath)).equal(true, 'none entry pre-deployment script is supposed to still exist on disk');
|
||||
should(await utils.exists(scriptEntry.fsUri.fsPath)).equal(true, 'script is supposed to still exist on disk');
|
||||
should(await utils.exists(preDeployEntry.fsUri.fsPath)).equal(true, 'pre-deployment script is supposed to still exist on disk');
|
||||
should(await utils.exists(postDeployEntry.fsUri.fsPath)).equal(true, 'post-deployment script is supposed to still exist on disk');
|
||||
should(await utils.exists(noneEntry.fsUri.fsPath)).equal(true, 'none entry pre-deployment script is supposed to still exist on disk');
|
||||
});
|
||||
|
||||
it('Should delete folders with excluded items', async function (): Promise<void> {
|
||||
@@ -287,9 +287,9 @@ describe('ProjectsController', function (): void {
|
||||
|
||||
// Confirm result
|
||||
should(proj.files.some(x => x.relativePath === 'UpperFolder')).equal(false, 'UpperFolder should not be part of proj file any more');
|
||||
should(await exists(scriptEntry.fsUri.fsPath)).equal(false, 'script is supposed to be deleted from disk');
|
||||
should(await exists(lowerFolder.projectUri.fsPath)).equal(false, 'LowerFolder is supposed to be deleted from disk');
|
||||
should(await exists(upperFolder.projectUri.fsPath)).equal(false, 'UpperFolder is supposed to be deleted from disk');
|
||||
should(await utils.exists(scriptEntry.fsUri.fsPath)).equal(false, 'script is supposed to be deleted from disk');
|
||||
should(await utils.exists(lowerFolder.projectUri.fsPath)).equal(false, 'LowerFolder is supposed to be deleted from disk');
|
||||
should(await utils.exists(upperFolder.projectUri.fsPath)).equal(false, 'UpperFolder is supposed to be deleted from disk');
|
||||
});
|
||||
|
||||
it('Should reload correctly after changing sqlproj file', async function (): Promise<void> {
|
||||
@@ -426,8 +426,7 @@ describe('ProjectsController', function (): void {
|
||||
builtDacpacPath = await testUtils.createTestFile(fakeDacpacContents, 'output.dacpac');
|
||||
return builtDacpacPath;
|
||||
});
|
||||
|
||||
projController.setup(x => x.getDaxFxService()).returns(() => Promise.resolve(testContext.dacFxService.object));
|
||||
sinon.stub(utils, 'getDacFxService').resolves(testContext.dacFxService.object);
|
||||
|
||||
const proj = await testUtils.createTestProject(baselines.openProjectFileBaseline);
|
||||
|
||||
|
||||
@@ -11,9 +11,8 @@ import * as TypeMoq from 'typemoq';
|
||||
import * as baselines from './baselines/baselines';
|
||||
import * as testUtils from './testUtils';
|
||||
import * as constants from '../common/constants';
|
||||
import { ProjectsController } from '../controllers/projectController';
|
||||
import { TestContext, createContext, mockDacFxOptionsResult } from './testContext';
|
||||
import { load } from '../models/publishProfile/publishProfile';
|
||||
import { load, readPublishProfile } from '../models/publishProfile/publishProfile';
|
||||
|
||||
let testContext: TestContext;
|
||||
|
||||
@@ -81,10 +80,9 @@ describe('Publish profile tests', function (): void {
|
||||
it('Should throw error when connecting does not work', async function (): Promise<void> {
|
||||
await baselines.loadBaselines();
|
||||
let profilePath = await testUtils.createTestFile(baselines.publishProfileIntegratedSecurityBaseline, 'publishProfile.publish.xml');
|
||||
const projController = new ProjectsController();
|
||||
|
||||
sinon.stub(azdata.connection, 'connect').throws(new Error('Could not connect'));
|
||||
|
||||
await testUtils.shouldThrowSpecificError(async () => await projController.readPublishProfileCallback(vscode.Uri.file(profilePath)), constants.unableToCreatePublishConnection('Could not connect'));
|
||||
await testUtils.shouldThrowSpecificError(async () => await readPublishProfile(vscode.Uri.file(profilePath)), constants.unableToCreatePublishConnection('Could not connect'));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user