From 18d40010f78b931103e1f06089657929a1c93447 Mon Sep 17 00:00:00 2001 From: Dayoung Lee Date: Fri, 4 Nov 2022 13:07:21 +0900 Subject: [PATCH] This commit clarifies the OneExplorer unit tests. (1) Elaborate `create a base model` test. (2) Add isDefined checker to easily notice undefined objects (3) Replace `?` with `!` to assert unexpected undefined objects ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee --- src/Tests/OneExplorer/OneExplorer.test.ts | 11 +++++------ src/Tests/OneExplorer/OneStorage.test.ts | 13 +++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Tests/OneExplorer/OneExplorer.test.ts b/src/Tests/OneExplorer/OneExplorer.test.ts index bdbaa089..fdf1697c 100644 --- a/src/Tests/OneExplorer/OneExplorer.test.ts +++ b/src/Tests/OneExplorer/OneExplorer.test.ts @@ -77,23 +77,22 @@ suite('OneExplorer', function() { }); }); - test('create a base model node with cfg', function() { + test('create a base model node outside workspace', function() { const baseModelName = 'test.tflite'; const configName = `test.cfg`; - // Write a file inside temp directory - // and get file paths inside the temp directory testBuilder.writeFileSync(baseModelName, ''); - const baseModelPath = testBuilder.getPath(baseModelName); + const baseModelPath = testBuilder.getPath(baseModelName); // in /tmp + const configPath = testBuilder.getPath(configName, 'workspace'); // in workspace + // Find a base model outside workspace by locating its absolute path testBuilder.writeFileSync( configName, ` [one-import-tflite] -input_file=${baseModelPath} +input_path=${baseModelPath} `, 'workspace'); - const configPath = testBuilder.getPath(configName, 'workspace'); // Validation { diff --git a/src/Tests/OneExplorer/OneStorage.test.ts b/src/Tests/OneExplorer/OneStorage.test.ts index 7e8668ba..eb7bd423 100644 --- a/src/Tests/OneExplorer/OneStorage.test.ts +++ b/src/Tests/OneExplorer/OneStorage.test.ts @@ -51,12 +51,13 @@ input_path=${modelName} const configPath = testBuilder.getPath(configName, 'workspace'); const modelPath = testBuilder.getPath(modelName, 'workspace'); - // Validation - { - assert.strictEqual(OneStorage.getCfgs(modelPath)?.length, 1); - assert.strictEqual(OneStorage.getCfgs(modelPath)![0], configPath); - } - }); + // Validation + { + assert.isDefined(OneStorage.getCfgs(modelPath)); + assert.strictEqual(OneStorage.getCfgs(modelPath)?.length, 1); + assert.strictEqual(OneStorage.getCfgs(modelPath)![0], configPath); + } + }); test('NEG: Returns undefined for not existing path', function() { { assert.isUndefined(OneStorage.getCfgs('invalid/path')); }