SQL Project - deploy to docker publish option (#17050)

SQL Project - deploy to docker publish option
This commit is contained in:
Leila Lali
2021-09-13 14:12:53 -07:00
committed by GitHub
parent 90bb9c3c55
commit 4912faa966
13 changed files with 158 additions and 143 deletions

View File

@@ -66,10 +66,6 @@ describe('deploy service', function (): void {
it('Should deploy a database to docker container successfully', async function (): Promise<void> {
const testContext = createContext();
const deployProfile: IDeployProfile = {
appSettingType: AppSettingType.AzureFunction,
appSettingFile: '',
deploySettings: undefined,
envVariableName: '',
localDbSetting: {
dbName: 'test',
password: 'PLACEHOLDER',
@@ -137,10 +133,6 @@ describe('deploy service', function (): void {
await fse.writeFile(filePath, settingContent);
const deployProfile: IDeployProfile = {
appSettingType: AppSettingType.AzureFunction,
appSettingFile: filePath,
deploySettings: undefined,
envVariableName: 'SQLConnectionString',
localDbSetting: {
dbName: 'test',
password: 'PLACEHOLDER',
@@ -150,9 +142,14 @@ describe('deploy service', function (): void {
}
};
const appInteg = {appSettingType: AppSettingType.AzureFunction,
appSettingFile: filePath,
deploySettings: undefined,
envVariableName: 'SQLConnectionString'};
const deployService = new DeployService(testContext.outputChannel);
sandbox.stub(childProcess, 'exec').yields(undefined, 'id');
await deployService.updateAppSettings(deployProfile);
await deployService.updateAppSettings(appInteg, deployProfile);
let newContent = JSON.parse(fse.readFileSync(filePath, 'utf8'));
should(newContent).deepEqual(expected);
@@ -184,23 +181,26 @@ describe('deploy service', function (): void {
await fse.writeFile(filePath, settingContent);
const deployProfile: IDeployProfile = {
appSettingType: AppSettingType.AzureFunction,
appSettingFile: filePath,
deploySettings: {
connectionUri: 'connection',
databaseName: 'test',
serverName: 'test'
},
envVariableName: 'SQLConnectionString',
localDbSetting: undefined
};
const appInteg = {
appSettingType: AppSettingType.AzureFunction,
appSettingFile: filePath,
envVariableName: 'SQLConnectionString',
}
const deployService = new DeployService(testContext.outputChannel);
let connection = new azdata.connection.ConnectionProfile();
sandbox.stub(azdata.connection, 'getConnection').returns(Promise.resolve(connection));
sandbox.stub(childProcess, 'exec').yields(undefined, 'id');
sandbox.stub(azdata.connection, 'getConnectionString').returns(Promise.resolve('connectionString'));
await deployService.updateAppSettings(deployProfile);
await deployService.updateAppSettings(appInteg, deployProfile);
let newContent = JSON.parse(fse.readFileSync(filePath, 'utf8'));
should(newContent).deepEqual(expected);

View File

@@ -7,7 +7,7 @@ import * as should from 'should';
import * as path from 'path';
import * as os from 'os';
import { createDummyFileStructure } from './testUtils';
import { exists, trimUri, removeSqlCmdVariableFormatting, formatSqlCmdVariable, isValidSqlCmdVariableName, timeConversion } from '../common/utils';
import { exists, trimUri, removeSqlCmdVariableFormatting, formatSqlCmdVariable, isValidSqlCmdVariableName, timeConversion, validateSqlServerPortNumber, isEmptyString } from '../common/utils';
import { Uri } from 'vscode';
describe('Tests to verify utils functions', function (): void {
@@ -88,5 +88,22 @@ describe('Tests to verify utils functions', function (): void {
should(timeConversion( (59 * 1000))).equal('59 sec');
should(timeConversion( (59))).equal('59 msec');
});
it('Should validate port number correctly', () => {
should(validateSqlServerPortNumber('invalid')).equals(false);
should(validateSqlServerPortNumber('')).equals(false);
should(validateSqlServerPortNumber(undefined)).equals(false);
should(validateSqlServerPortNumber('65536')).equals(false);
should(validateSqlServerPortNumber('-1')).equals(false);
should(validateSqlServerPortNumber('65530')).equals(true);
should(validateSqlServerPortNumber('1533')).equals(true);
});
it('Should validate empty string correctly', () => {
should(isEmptyString('invalid')).equals(false);
should(isEmptyString('')).equals(true);
should(isEmptyString(undefined)).equals(true);
should(isEmptyString('65536')).equals(false);
});
});