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

Commit b3546a2

Browse files
[Fix] Issue 905 where test is failing because Task API cannot be reached (#210)
* [Fix] Issue 905 where test is failing because Task API cannot be reached * Update azure-pipelines.yml Adding a timeout Co-authored-by: Andre Briggs <andrebriggs@users.noreply.github.com>
1 parent a91a742 commit b3546a2

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ steps:
4343
- script: |
4444
yarn test
4545
displayName: "YARN TEST"
46+
timeoutInMinutes: 3
4647
4748
- task: PublishCodeCoverageResults@1
4849
inputs:

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import mockFs from "mock-fs";
44
import os from "os";
55
import path from "path";
66
import uuid from "uuid/v4";
7-
import { Bedrock, readYaml, write } from "../../config";
7+
import { readYaml, write } from "../../config";
88
import { IAzureDevOpsOpts } from "../../lib/git";
9+
import * as pipelineVariableGroup from "../../lib/pipelines/variableGroup";
910
import {
1011
disableVerboseLogging,
1112
enableVerboseLogging,
@@ -207,14 +208,25 @@ describe("create", () => {
207208
expect(invalidDataError).toBeDefined();
208209
});
209210

210-
test("Should pass with empty variable group arguments", async () => {
211+
test("Should pass with variable group arguments", async () => {
212+
// mock the function that calls the Azdo project's Task API
213+
// because unit test is unable to reach this API.
214+
// all the validation of parameters passed into create
215+
// function succeeds
216+
const doAddVariableGroupMock = jest.spyOn(
217+
pipelineVariableGroup,
218+
"doAddVariableGroup"
219+
);
220+
doAddVariableGroupMock.mockImplementation(() => {
221+
return Promise.resolve({});
222+
});
223+
211224
const accessOpts: IAzureDevOpsOpts = {
212225
orgName,
213226
personalAccessToken,
214227
project
215228
};
216229

217-
let invalidGroupError: Error | undefined;
218230
try {
219231
logger.info("calling create");
220232
await create(
@@ -227,9 +239,9 @@ describe("create", () => {
227239
accessOpts
228240
);
229241
} catch (err) {
230-
invalidGroupError = err;
242+
// should not reach here
243+
expect(true).toBe(false);
231244
}
232-
expect(invalidGroupError).toBeDefined();
233245
});
234246
});
235247

0 commit comments

Comments
 (0)