mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Increase test coverage of admin-tool-ext-win (#9619)
This commit is contained in:
@@ -232,8 +232,8 @@ async function launchSsmsDialog(action: string, connectionContext: azdata.Object
|
|||||||
* @param params The params used to build up the command parameter string
|
* @param params The params used to build up the command parameter string
|
||||||
*/
|
*/
|
||||||
export function buildSsmsMinCommandArgs(params: LaunchSsmsDialogParams): string {
|
export function buildSsmsMinCommandArgs(params: LaunchSsmsDialogParams): string {
|
||||||
return `${params.action ? '-a "' + backEscapeDoubleQuotes(params.action) + '"' : ''}\
|
return `-a "${backEscapeDoubleQuotes(params.action)}" \
|
||||||
${params.server ? ' -S "' + backEscapeDoubleQuotes(params.server) + '"' : ''}\
|
-S "${backEscapeDoubleQuotes(params.server)}"\
|
||||||
${params.database ? ' -D "' + backEscapeDoubleQuotes(params.database) + '"' : ''}\
|
${params.database ? ' -D "' + backEscapeDoubleQuotes(params.database) + '"' : ''}\
|
||||||
${params.user ? ' -U "' + backEscapeDoubleQuotes(params.user) + '"' : ''}\
|
${params.user ? ' -U "' + backEscapeDoubleQuotes(params.user) + '"' : ''}\
|
||||||
${params.useAad === true ? ' -G' : ''}\
|
${params.useAad === true ? ' -G' : ''}\
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import * as should from 'should';
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
|
||||||
import { buildSsmsMinCommandArgs, buildUrn, LaunchSsmsDialogParams } from '../main';
|
import { buildSsmsMinCommandArgs, buildUrn, LaunchSsmsDialogParams } from '../main';
|
||||||
import { doubleEscapeSingleQuotes, backEscapeDoubleQuotes } from '../utils';
|
import { doubleEscapeSingleQuotes, backEscapeDoubleQuotes, getTelemetryErrorType } from '../utils';
|
||||||
import { ExtHostObjectExplorerNodeStub } from './stubs';
|
import { ExtHostObjectExplorerNodeStub } from './stubs';
|
||||||
|
|
||||||
describe('buildSsmsMinCommandArgs Method Tests', () => {
|
describe('buildSsmsMinCommandArgs Method Tests', () => {
|
||||||
@@ -73,13 +73,14 @@ const tableSchema = 'tbl\'sch';
|
|||||||
const escapedTableSchema = doubleEscapeSingleQuotes(tableSchema);
|
const escapedTableSchema = doubleEscapeSingleQuotes(tableSchema);
|
||||||
|
|
||||||
describe('buildUrn Method Tests', () => {
|
describe('buildUrn Method Tests', () => {
|
||||||
it('Urn should be correct with just server', async function (): Promise<void> {
|
it('Urn should be correct with no node', async function (): Promise<void> {
|
||||||
should(await buildUrn(undefined)).equal('Server');
|
should(await buildUrn(undefined)).equal('Server');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Urn should be correct with Server and only Databases folder', async function (): Promise<void> {
|
it('Urn should be correct with Server and only Databases folder', async function (): Promise<void> {
|
||||||
const leafNode: ExtHostObjectExplorerNodeStub =
|
const leafNode: ExtHostObjectExplorerNodeStub =
|
||||||
new ExtHostObjectExplorerNodeStub('Databases', undefined, 'Folder', undefined);
|
new ExtHostObjectExplorerNodeStub('MyServer', undefined, 'Server', undefined)
|
||||||
|
.createChild('Databases', undefined, 'Folder');
|
||||||
should(await buildUrn(leafNode)).equal('Server');
|
should(await buildUrn(leafNode)).equal('Server');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -100,6 +101,16 @@ describe('buildUrn Method Tests', () => {
|
|||||||
should(await buildUrn(rootNode)).equal(
|
should(await buildUrn(rootNode)).equal(
|
||||||
`Server/Database[@Name='${escapedDbName}' and @Schema='${escapedDbSchema}']/Table[@Name='${escapedTableName}' and @Schema='${escapedTableSchema}']`);
|
`Server/Database[@Name='${escapedDbName}' and @Schema='${escapedDbSchema}']/Table[@Name='${escapedTableName}' and @Schema='${escapedTableSchema}']`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Urn should be correct with Multiple levels of Nodes without schemas', async function (): Promise<void> {
|
||||||
|
const rootNode: ExtHostObjectExplorerNodeStub =
|
||||||
|
new ExtHostObjectExplorerNodeStub('Databases', undefined, 'Folder', undefined)
|
||||||
|
.createChild(dbName, undefined, 'Database')
|
||||||
|
.createChild('Tables', undefined, 'Folder')
|
||||||
|
.createChild(tableName, undefined, 'Table');
|
||||||
|
should(await buildUrn(rootNode)).equal(
|
||||||
|
`Server/Database[@Name='${escapedDbName}']/Table[@Name='${escapedTableName}']`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('doubleEscapeSingleQuotes Method Tests', () => {
|
describe('doubleEscapeSingleQuotes Method Tests', () => {
|
||||||
@@ -129,3 +140,30 @@ describe('backEscapeDoubleQuotes Method Tests', () => {
|
|||||||
should(ret).equal('MyTestString\\"\\"WithQuotes');
|
should(ret).equal('MyTestString\\"\\"WithQuotes');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getTelemetryErrorType Method Tests', () => {
|
||||||
|
it('ExeNotFound', function (): void {
|
||||||
|
const msg = getTelemetryErrorType('SsmsMin.exe is not recognized as an internal or external command');
|
||||||
|
should(msg).equal('ExeNotFound');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('UnknownAction', function (): void {
|
||||||
|
const msg = getTelemetryErrorType('Unknown Action "foo"');
|
||||||
|
should(msg).equal('UnknownAction');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('NoActionProvided', function (): void {
|
||||||
|
const msg = getTelemetryErrorType('No Action Provided');
|
||||||
|
should(msg).equal('NoActionProvided');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('RunException', function (): void {
|
||||||
|
const msg = getTelemetryErrorType('Run exception "Error occurred"');
|
||||||
|
should(msg).equal('RunException');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Other', function (): void {
|
||||||
|
const msg = getTelemetryErrorType('Some other error message');
|
||||||
|
should(msg).equal('Other');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -9,15 +9,12 @@ export interface IPackageInfo {
|
|||||||
aiKey: string;
|
aiKey: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPackageInfo(packageJson: any): IPackageInfo | undefined {
|
export function getPackageInfo(packageJson: any): IPackageInfo {
|
||||||
if (packageJson) {
|
return {
|
||||||
return {
|
name: packageJson.name,
|
||||||
name: packageJson.name,
|
version: packageJson.version,
|
||||||
version: packageJson.version,
|
aiKey: packageJson.aiKey
|
||||||
aiKey: packageJson.aiKey
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user