mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-05 09:35:39 -05:00
Added in auto-install prompt for Azure CLI and arcdata extension, "Don't Ask Again" logic, removed waiting on azcli extension activate (#16646)
* Added back Don't Ask Again logic * If no Azure CLI found, throw error instead of returning undefined. * Deleted 'restart ADS' text for arcdata extension prompts * Added error catch for parse version and parsed out the * in az --version * Added back findAz() * Added arcdata version to AzTool. Parse --version using regex. * Return undefined if no az found. * Added userRequested param for findAz * No longer await on extension activate. Re-added some functions for az install. * Install works for windows * Changed auto install for az on Linux and MacOS. * Added comment for findSpecificAzAndArc and uncommented some localizedConstants * Added comment for getSemVersionArc and took out the path for some tests. * Made findSpecificAzAndArc return an object instead of a list * Removed azToolService test * Removed azToolService tests and renamed suite to azcli Extension Tests * Got rid of new Regexp for regex in parseVersions * Added back azToolService.ts * Added logic to enable prompt user to install arcdata extension and auto-install capability. No update capability yet. Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
151
extensions/azcli/src/test/az.test.ts
Normal file
151
extensions/azcli/src/test/az.test.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as should from 'should';
|
||||
import * as sinon from 'sinon';
|
||||
import * as childProcess from '../common/childProcess';
|
||||
import * as az from '../az';
|
||||
|
||||
describe('az', function () {
|
||||
afterEach(function (): void {
|
||||
sinon.restore();
|
||||
});
|
||||
describe('azTool', function (): void {
|
||||
const azTool = new az.AzTool('my path', '2.26.0', '1.0.0');
|
||||
let executeCommandStub: sinon.SinonStub;
|
||||
const namespace = 'arc';
|
||||
const name = 'arcdc';
|
||||
|
||||
beforeEach(function (): void {
|
||||
executeCommandStub = sinon.stub(childProcess, 'executeCommand').resolves({ stdout: '{}', stderr: '' });
|
||||
});
|
||||
|
||||
describe('arcdata', function (): void {
|
||||
describe('dc', function (): void {
|
||||
describe('endpoint', async function (): Promise<void> {
|
||||
it('list', async function (): Promise<void> {
|
||||
await azTool.arcdata.dc.endpoint.list(namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['arcdata', 'dc', 'endpoint', 'list', '--k8s-namespace', namespace, '--use-k8s']);
|
||||
});
|
||||
});
|
||||
describe('config', async function (): Promise<void> {
|
||||
it('list', async function (): Promise<void> {
|
||||
await azTool.arcdata.dc.config.list();
|
||||
verifyExecuteCommandCalledWithArgs(['arcdata', 'dc', 'config', 'list']);
|
||||
});
|
||||
it('show', async function (): Promise<void> {
|
||||
await azTool.arcdata.dc.config.show(namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['arcdata', 'dc', 'config', 'show', '--k8s-namespace', namespace, '--use-k8s']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('postgres', function (): void {
|
||||
describe('arc-server', function (): void {
|
||||
it('delete', async function (): Promise<void> {
|
||||
await azTool.postgres.arcserver.delete(name, namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['postgres', 'arc-server', 'delete', name, '--k8s-namespace', namespace]);
|
||||
});
|
||||
it('list', async function (): Promise<void> {
|
||||
await azTool.postgres.arcserver.list(namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['postgres', 'arc-server', 'list', '--k8s-namespace', namespace]);
|
||||
});
|
||||
it('show', async function (): Promise<void> {
|
||||
await azTool.postgres.arcserver.show(name, namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['postgres', 'arc-server', 'show', name, '--k8s-namespace', namespace]);
|
||||
});
|
||||
it('edit', async function (): Promise<void> {
|
||||
const args = {
|
||||
adminPassword: true,
|
||||
coresLimit: 'myCoresLimit',
|
||||
coresRequest: 'myCoresRequest',
|
||||
engineSettings: 'myEngineSettings',
|
||||
extensions: 'myExtensions',
|
||||
memoryLimit: 'myMemoryLimit',
|
||||
memoryRequest: 'myMemoryRequest',
|
||||
noWait: true,
|
||||
port: 1337,
|
||||
replaceEngineSettings: true,
|
||||
workers: 2
|
||||
};
|
||||
await azTool.postgres.arcserver.edit(name, args, namespace);
|
||||
verifyExecuteCommandCalledWithArgs([
|
||||
'postgres', 'arc-server', 'edit',
|
||||
name,
|
||||
'--admin-password',
|
||||
args.coresLimit,
|
||||
args.coresRequest,
|
||||
args.engineSettings,
|
||||
args.extensions,
|
||||
args.memoryLimit,
|
||||
args.memoryRequest,
|
||||
'--no-wait',
|
||||
args.port.toString(),
|
||||
'--replace-engine-settings',
|
||||
args.workers.toString()]);
|
||||
});
|
||||
it('edit no optional args', async function (): Promise<void> {
|
||||
await azTool.postgres.arcserver.edit(name, {}, namespace);
|
||||
verifyExecuteCommandCalledWithArgs([
|
||||
'postgres', 'arc-server', 'edit',
|
||||
name]);
|
||||
verifyExecuteCommandCalledWithoutArgs([
|
||||
'--admin-password',
|
||||
'--cores-limit',
|
||||
'--cores-request',
|
||||
'--engine-settings',
|
||||
'--extensions',
|
||||
'--memory-limit',
|
||||
'--memory-request',
|
||||
'--no-wait',
|
||||
'--port',
|
||||
'--replace-engine-settings',
|
||||
'--workers']);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('sql', function (): void {
|
||||
describe('mi-arc', function (): void {
|
||||
it('delete', async function (): Promise<void> {
|
||||
await azTool.sql.miarc.delete(name, namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['sql', 'mi-arc', 'delete', name, '--k8s-namespace', namespace, '--use-k8s']);
|
||||
});
|
||||
it('list', async function (): Promise<void> {
|
||||
await azTool.sql.miarc.list(namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['sql', 'mi-arc', 'list', '--k8s-namespace', namespace, '--use-k8s']);
|
||||
});
|
||||
it('show', async function (): Promise<void> {
|
||||
await azTool.sql.miarc.show(name, namespace);
|
||||
verifyExecuteCommandCalledWithArgs(['sql', 'mi-arc', 'show', name, '--k8s-namespace', namespace, '--use-k8s']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('version', async function (): Promise<void> {
|
||||
executeCommandStub.resolves({ stdout: '1.0.0', stderr: '' });
|
||||
await azTool.version();
|
||||
verifyExecuteCommandCalledWithArgs(['--version']);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verifies that the specified args were included in the call to executeCommand
|
||||
* @param args The args to check were included in the execute command call
|
||||
*/
|
||||
function verifyExecuteCommandCalledWithArgs(args: string[], callIndex = 0): void {
|
||||
const commandArgs = executeCommandStub.args[callIndex][1] as string[];
|
||||
args.forEach(arg => should(commandArgs).containEql(arg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the specified args weren't included in the call to executeCommand
|
||||
* @param args The args to check weren't included in the execute command call
|
||||
*/
|
||||
function verifyExecuteCommandCalledWithoutArgs(args: string[]): void {
|
||||
const commandArgs = executeCommandStub.args[0][1] as string[];
|
||||
args.forEach(arg => should(commandArgs).not.containEql(arg));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -13,10 +13,10 @@ describe('az', function () {
|
||||
sinon.restore();
|
||||
});
|
||||
describe('azTool', function (): void {
|
||||
const azTool = new azdata.AzTool('C:/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin/az.cmd', '2.26.0');
|
||||
const azTool = new azdata.AzTool('my path', '2.26.0', '1.0.0');
|
||||
let executeCommandStub: sinon.SinonStub;
|
||||
const namespace = 'arc4';
|
||||
const name = 'cy-dc-4';
|
||||
const namespace = 'arc';
|
||||
const name = 'dc';
|
||||
|
||||
beforeEach(function (): void {
|
||||
executeCommandStub = sinon.stub(childProcess, 'executeCommand').resolves({ stdout: '{}', stderr: '' });
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as path from 'path';
|
||||
const testRunner = require('vscodetestcover');
|
||||
|
||||
const suite = 'azdata Extension Tests';
|
||||
const suite = 'azcli Extension Tests';
|
||||
|
||||
const mochaOptions: any = {
|
||||
ui: 'bdd',
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as should from 'should';
|
||||
import { AzTool } from '../../az';
|
||||
import { AzToolService } from '../../services/azToolService';
|
||||
|
||||
describe('azToolService', function (): void {
|
||||
it('Tool should be set correctly', async function (): Promise<void> {
|
||||
const service = new AzToolService();
|
||||
should(service.localAz).be.undefined();
|
||||
service.localAz = new AzTool('my path', '1.0.0');
|
||||
should(service).not.be.undefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user