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:
Charles Gagnon
2021-04-22 09:03:48 -07:00
committed by GitHub
parent 2f02b0bb52
commit 599a64c631
2 changed files with 68 additions and 51 deletions

View File

@@ -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');
}