Skip to content

Commit 3664803

Browse files
committed
Add tests for creating model file
1 parent 9bc5344 commit 3664803

File tree

2 files changed

+475
-10
lines changed

2 files changed

+475
-10
lines changed

extensions/ql-vscode/src/data-extensions-editor/extension-pack-picker.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async function pickNewModelFile(
176176
return undefined;
177177
}
178178

179-
const dataExtensionPatternsValue = qlpack.dataExtensions ?? [];
179+
const dataExtensionPatternsValue = qlpack.dataExtensions;
180180
if (
181181
!(
182182
Array.isArray(dataExtensionPatternsValue) ||
@@ -199,16 +199,19 @@ async function pickNewModelFile(
199199
title: "Enter the name of the new model file",
200200
value: `models/${databaseItem.name.replaceAll("/", ".")}.model.yml`,
201201
validateInput: async (value: string): Promise<string | undefined> => {
202+
if (value === "") {
203+
return "File name must not be empty";
204+
}
205+
202206
const path = resolve(extensionPackPath, value);
203207

204208
if (await pathExists(path)) {
205209
return "File already exists";
206210
}
207211

208-
const notInExtensionPack = !relative(
209-
extensionPackPath,
210-
path,
211-
).startsWith("..");
212+
const notInExtensionPack = relative(extensionPackPath, path).startsWith(
213+
"..",
214+
);
212215
if (notInExtensionPack) {
213216
return "File must be in the extension pack";
214217
}

0 commit comments

Comments
 (0)