Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 7fd1606

Browse files
authored
[BUG-FIX] added validation to create function (#456)
1 parent e93afc3 commit 7fd1606

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/commands/project/create-variable-group.test.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,14 @@ describe("create", () => {
147147
personalAccessToken,
148148
project: devopsProject,
149149
};
150-
await expect(create("", "", "", "", "", "", accessOpts)).rejects.toThrow();
150+
151+
// for some reasons, cannot get the await expect(...).rejects.toThrow() to work
152+
try {
153+
await create("", "", "", "", "", "", accessOpts);
154+
expect(true).toBeFalsy();
155+
} catch (e) {
156+
expect(e.message).toBe("Required values were missing");
157+
}
151158
});
152159

153160
test("Should pass with variable group arguments", async () => {

src/commands/project/create-variable-group.ts

+10
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ export const create = (
191191
`Creating Variable Group from group definition '${variableGroupName}'`
192192
);
193193

194+
if (
195+
!registryName ||
196+
!hldRepoUrl ||
197+
!servicePrincipalId ||
198+
!servicePrincipalPassword ||
199+
!tenantId
200+
) {
201+
throw Error("Required values were missing");
202+
}
203+
194204
const vars: VariableGroupDataVariable = {
195205
ACR_NAME: {
196206
value: registryName,

0 commit comments

Comments
 (0)