Skip to content

Commit

Permalink
This commit clarifies the OneExplorer unit tests.
Browse files Browse the repository at this point in the history
(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 <[email protected]>
  • Loading branch information
dayo09 committed Nov 4, 2022
1 parent e5dd2b7 commit 18d4001
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/Tests/OneExplorer/OneExplorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
13 changes: 7 additions & 6 deletions src/Tests/OneExplorer/OneStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')); }
Expand Down

0 comments on commit 18d4001

Please sign in to comment.