-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for status bar functionality
- Loading branch information
Showing
8 changed files
with
52 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import { execCLICommand } from '../utils/shell'; | ||
import { Shell } from '../utils/shell'; | ||
|
||
/** | ||
* Fetches the current active stack using the ZenML CLI. | ||
* | ||
* @param {Function} execCLICommand - Optional. Custom function to execute CLI commands, intended | ||
* for testing with mocks or stubs. | ||
* @returns {Promise<string>} Promise resolving with the name of the current active stack. | ||
*/ | ||
export function getActiveStack(): Promise<string> { | ||
return execCLICommand('zenml stack get'); | ||
export async function getActiveStack(execCLICommand: Function = Shell.execCLICommand): Promise<string> { | ||
return await execCLICommand('zenml stack get'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import * as assert from 'assert'; | ||
|
||
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
import * as vscode from 'vscode'; | ||
// import * as myExtension from '../../extension'; | ||
|
||
suite('Extension Test Suite', () => { | ||
vscode.window.showInformationMessage('Start all tests.'); | ||
test('Extension should be present', () => { | ||
assert.ok(vscode.extensions.getExtension('zenml.zenml-studio')); | ||
}); | ||
|
||
test('Sample test', () => { | ||
assert.strictEqual(-1, [1, 2, 3].indexOf(5)); | ||
assert.strictEqual(-1, [1, 2, 3].indexOf(0)); | ||
test('Extension should activate', async () => { | ||
const extension = vscode.extensions.getExtension('zenml.zenml-studio'); | ||
if (extension) { | ||
await extension.activate(); | ||
assert.ok(extension.isActive, 'Extension did not activate as expected.'); | ||
} else { | ||
assert.fail('Extension zenml-studio could not be found.'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { exec } from 'child_process'; | ||
|
||
/** | ||
* Executes a CLI command and returns a promise that resolves with the command's stdout. | ||
*/ | ||
export function execCLICommand(command: string): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
|
||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
reject(error); | ||
return; | ||
} | ||
resolve(stdout.trim()); | ||
export class Shell { | ||
/** | ||
* Executes a CLI command and returns a promise that resolves with the command's stdout. | ||
*/ | ||
static execCLICommand(command: string): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
reject(error); | ||
return; | ||
} | ||
resolve(stdout.trim()); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters