Add deploy options support (#11567)

* add getOptionsFromProfile request

* update deploy and generate script to accept options

* fix tests

* update message

* update message to say what isn't supported

* bump sqltoolsservice version
This commit is contained in:
Kim Santiago
2020-07-29 17:52:21 -07:00
committed by GitHub
parent 6751dffbc3
commit c06bd0821b
13 changed files with 249 additions and 22 deletions

View File

@@ -7,18 +7,26 @@ import * as should from 'should';
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import * as sinon from 'sinon';
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 { SqlDatabaseProjectTreeViewProvider } from '../controllers/databaseProjectTreeViewProvider';
import { TestContext, createContext, mockDacFxOptionsResult } from './testContext';
import { load } from '../models/publishProfile/publishProfile';
let testContext: TestContext;
describe('Publish profile tests', function (): void {
before(async function (): Promise<void> {
await baselines.loadBaselines();
});
beforeEach(function (): void {
testContext = createContext();
});
afterEach(function (): void {
sinon.restore();
});
@@ -26,44 +34,50 @@ describe('Publish profile tests', function (): void {
it('Should read database name, integrated security connection string, and SQLCMD variables from publish profile', async function (): Promise<void> {
await baselines.loadBaselines();
let profilePath = await testUtils.createTestFile(baselines.publishProfileIntegratedSecurityBaseline, 'publishProfile.publish.xml');
const projController = new ProjectsController(new SqlDatabaseProjectTreeViewProvider());
const connectionResult = {
connected: true,
connectionId: 'connId',
errorMessage: '',
errorCode: 0
};
testContext.dacFxService.setup(x => x.getOptionsFromProfile(TypeMoq.It.isAny())).returns(async () => {
return Promise.resolve(mockDacFxOptionsResult);
});
const connectionString = 'Data Source=testserver;Integrated Security=true;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True';
sinon.stub(azdata.connection, 'connect').resolves(connectionResult);
sinon.stub(azdata.connection, 'getConnectionString').resolves(connectionString);
let result = await projController.readPublishProfileCallback(vscode.Uri.file(profilePath));
let result = await load(vscode.Uri.file(profilePath), testContext.dacFxService.object);
should(result.databaseName).equal('targetDb');
should(Object.keys(result.sqlCmdVariables).length).equal(1);
should(result.sqlCmdVariables['ProdDatabaseName']).equal('MyProdDatabase');
should(result.connectionId).equal('connId');
should(result.connectionString).equal('Data Source=testserver;Integrated Security=true;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True');
should(result.options).equal(mockDacFxOptionsResult.deploymentOptions);
});
it('Should read database name, SQL login connection string, and SQLCMD variables from publish profile', async function (): Promise<void> {
await baselines.loadBaselines();
let profilePath = await testUtils.createTestFile(baselines.publishProfileSqlLoginBaseline, 'publishProfile.publish.xml');
const projController = new ProjectsController(new SqlDatabaseProjectTreeViewProvider());
const connectionResult = {
providerName: 'MSSQL',
connectionId: 'connId',
options: {}
};
testContext.dacFxService.setup(x => x.getOptionsFromProfile(TypeMoq.It.isAny())).returns(async () => {
return Promise.resolve(mockDacFxOptionsResult);
});
const connectionString = 'Data Source=testserver;User Id=testUser;Password=******;Integrated Security=false;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True';
sinon.stub(azdata.connection, 'openConnectionDialog').resolves(connectionResult);
sinon.stub(azdata.connection, 'getConnectionString').resolves(connectionString);
let result = await projController.readPublishProfileCallback(vscode.Uri.file(profilePath));
let result = await load(vscode.Uri.file(profilePath), testContext.dacFxService.object);
should(result.databaseName).equal('targetDb');
should(Object.keys(result.sqlCmdVariables).length).equal(1);
should(result.sqlCmdVariables['ProdDatabaseName']).equal('MyProdDatabase');
should(result.connectionId).equal('connId');
should(result.connectionString).equal('Data Source=testserver;User Id=testUser;Password=******;Integrated Security=false;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True');
should(result.options).equal(mockDacFxOptionsResult.deploymentOptions);
});
it('Should throw error when connecting does not work', async function (): Promise<void> {