mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 11:08:31 -05:00
Add encoded path name tests for SQL kernel (#15197)
* Add encoded path name tests for SQL kernel * Remove invocation count
This commit is contained in:
@@ -162,19 +162,23 @@ export const pythonKernelSpec: azdata.nb.IKernelSpec = {
|
||||
display_name: 'Python 3'
|
||||
};
|
||||
|
||||
export function writeNotebookToFile(pythonNotebook: azdata.nb.INotebookContents, testName: string): vscode.Uri {
|
||||
let fileName = getFileName(testName);
|
||||
export function writeNotebookToFile(pythonNotebook: azdata.nb.INotebookContents, relativeFilePath: string): vscode.Uri {
|
||||
let fileName = getTempFilePath(relativeFilePath);
|
||||
let notebookContentString = JSON.stringify(pythonNotebook);
|
||||
// eslint-disable-next-line no-sync
|
||||
fs.mkdirSync(path.dirname(fileName), { recursive: true });
|
||||
// eslint-disable-next-line no-sync
|
||||
fs.writeFileSync(fileName, notebookContentString);
|
||||
console.log(`Local file is created: '${fileName}'`);
|
||||
let uri = vscode.Uri.file(fileName);
|
||||
return uri;
|
||||
}
|
||||
|
||||
export function getFileName(testName: string): string {
|
||||
if (testName) {
|
||||
return path.join(os.tmpdir(), testName + '.ipynb');
|
||||
}
|
||||
return undefined;
|
||||
/**
|
||||
* Creates the path of a file in the temp directory
|
||||
* @param relativeFilePath The relative path of the file in the temp directory
|
||||
* @returns The full path of the file
|
||||
*/
|
||||
export function getTempFilePath(relativeFilePath: string): string {
|
||||
return path.join(os.tmpdir(), relativeFilePath + '.ipynb');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user