mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 01:32:34 -05:00
Run ADS Commands from Notebooks (#11069)
* Run commands * cleanup * Plumbed through error and message output * undo unnecessary changes * Remove change to fix tests * pr feedback
This commit is contained in:
@@ -10,7 +10,7 @@ import { nb, ServerInfo } from 'azdata';
|
||||
import { getHostAndPortFromEndpoint, isStream, getProvidersForFileName, asyncForEach, clusterEndpointsProperty, getClusterEndpoints, RawEndpoint, IEndpoint, getStandardKernelsForProvider, IStandardKernelWithProvider, rewriteUrlUsingRegex } from 'sql/workbench/services/notebook/browser/models/notebookUtils';
|
||||
import { INotebookService, DEFAULT_NOTEBOOK_FILETYPE, DEFAULT_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NotebookServiceStub } from 'sql/workbench/contrib/notebook/test/stubs';
|
||||
import { tryMatchCellMagic } from 'sql/workbench/services/notebook/browser/utils';
|
||||
import { tryMatchCellMagic, extractCellMagicCommandPlusArgs } from 'sql/workbench/services/notebook/browser/utils';
|
||||
|
||||
suite('notebookUtils', function (): void {
|
||||
const mockNotebookService = TypeMoq.Mock.ofType<INotebookService>(NotebookServiceStub);
|
||||
@@ -121,6 +121,51 @@ suite('notebookUtils', function (): void {
|
||||
assert.strictEqual(result, null);
|
||||
});
|
||||
|
||||
test('extractCellMagicCommandPlusArgs Test', async function (): Promise<void> {
|
||||
let result = extractCellMagicCommandPlusArgs(undefined, undefined);
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('test', undefined);
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs(undefined, 'test');
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic', 'magic');
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic ', 'magic');
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('magic', 'magic');
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('magic ', 'magic');
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command', 'otherMagic');
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magiccommand', 'magic');
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command', 'magic');
|
||||
assert.equal(result.commandId, 'command');
|
||||
assert.equal(result.args, '');
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command arg1', 'magic');
|
||||
assert.equal(result.commandId, 'command');
|
||||
assert.equal(result.args, 'arg1');
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command arg1 arg2', 'magic');
|
||||
assert.equal(result.commandId, 'command');
|
||||
assert.equal(result.args, 'arg1 arg2');
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command.id arg1 arg2 arg3', 'magic');
|
||||
assert.equal(result.commandId, 'command.id');
|
||||
assert.equal(result.args, 'arg1 arg2 arg3');
|
||||
});
|
||||
|
||||
test('asyncForEach Test', async function (): Promise<void> {
|
||||
let totalResult = 0;
|
||||
await asyncForEach([1, 2, 3, 4], async (value) => {
|
||||
|
||||
Reference in New Issue
Block a user