Skip to content

Commit 72ab795

Browse files
authored
Fix UnityGetProjectVersionV1 tests (#280)
* Update gitignore to exlude taskkey for testing * Do not build when running test * Add PR trigger
1 parent 62f4118 commit 72ab795

File tree

4 files changed

+46
-29
lines changed

4 files changed

+46
-29
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Build, Test and Deploy
22

33
on:
4+
pull_request:
5+
branches: [ main, development ]
46
push:
57
branches: [ main, development ]
68

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,7 @@ dist
105105

106106
*.js
107107
*.vsix
108-
.vs/
108+
.vs/
109+
110+
# Azure DevOps extensions
111+
.taskkey

Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "unity-get-project-version.js",
66
"scripts": {
77
"build": "tsc",
8-
"test": "npm run build && nyc mocha test/_suite.js",
8+
"test": "nyc mocha test/_suite.js",
99
"upload": "tfx build tasks upload --task-path ./",
1010
"dev-delete": "tfx build tasks delete --task-id 38ec98bf-601a-4390-9f2e-23d43dd6dbba",
1111
"dev-upload": "npm run build && npm run upload"

Tasks/UnityGetProjectVersion/UnityGetProjectVersionV1/test/_suite.ts

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,70 @@ import assert from 'assert';
22
import * as mocktest from 'azure-pipelines-task-lib/mock-test';
33
import * as path from 'path';
44

5-
describe("Unity Get Project Version", async () => {
6-
it("Error determining the project version from file", async () => {
5+
describe("Unity Get Project Version", () => {
6+
it("Error determining the project version from file", (done) => {
77
let testPath = path.join(__dirname, 'errorDeterminingTheProjectVersionFromFile.js');
88

99
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
1010

11-
await runner.runAsync();
11+
runner.runAsync()
12+
.then(() => {
13+
assert.strictEqual(runner.failed, true);
14+
assert.strictEqual(runner.invokedToolCount, 0);
15+
assert(runner.stdOutContained('loc_mock_failGetUnityEditorVersion | Unknown project version format encountered'));
1216

13-
assert.strictEqual(runner.failed, true);
14-
assert.strictEqual(runner.invokedToolCount, 0);
15-
assert(runner.stdOutContained('loc_mock_failGetUnityEditorVersion | Unknown project version format encountered'));
17+
done();
18+
});
1619
})
1720

18-
it("Success (alpha) determining the project version from file", async () => {
21+
it("Success (alpha) determining the project version from file", (done) => {
1922
let testPath = path.join(__dirname, 'successAlphaDeterminingTheProjectVersionFromFile.js');
2023

2124
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
2225

23-
await runner.runAsync();
26+
runner.runAsync()
27+
.then(() => {
28+
assert.strictEqual(runner.succeeded, true);
29+
assert.strictEqual(runner.invokedToolCount, 0);
30+
assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49a1, revision=4dae1bb8668d, alpha=true, beta=false'));
31+
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49a1'));
32+
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d'));
2433

25-
assert.strictEqual(runner.succeeded, true);
26-
assert.strictEqual(runner.invokedToolCount, 0);
27-
assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49a1, revision=4dae1bb8668d, alpha=true, beta=false'));
28-
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49a1'));
29-
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d'));
34+
done();
35+
});
3036
})
3137

32-
it("Success (beta) determining the project version from file", async () => {
38+
it("Success (beta) determining the project version from file", (done) => {
3339
let testPath = path.join(__dirname, 'successBetaDeterminingTheProjectVersionFromFile.js');
3440

3541
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
3642

37-
await runner.runAsync();
43+
runner.runAsync()
44+
.then(() => {
45+
assert.strictEqual(runner.succeeded, true);
46+
assert.strictEqual(runner.invokedToolCount, 0);
47+
assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49b1, revision=4dae1bb8668d, alpha=false, beta=true'));
48+
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49b1'));
49+
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d'));
3850

39-
assert.strictEqual(runner.succeeded, true);
40-
assert.strictEqual(runner.invokedToolCount, 0);
41-
assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49b1, revision=4dae1bb8668d, alpha=false, beta=true'));
42-
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49b1'));
43-
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d'));
51+
done();
52+
});
4453
})
4554

46-
it("Success (stable) determining the project version from file", async () => {
55+
it("Success (stable) determining the project version from file", (done) => {
4756
let testPath = path.join(__dirname, 'successStableDeterminingTheProjectVersionFromFile.js');
4857

4958
let runner: mocktest.MockTestRunner = new mocktest.MockTestRunner(testPath);
5059

51-
await runner.runAsync();
60+
runner.runAsync()
61+
.then(() => {
62+
assert.strictEqual(runner.succeeded, true);
63+
assert.strictEqual(runner.invokedToolCount, 0);
64+
assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49f1, revision=4dae1bb8668d, alpha=false, beta=false'));
65+
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49f1'));
66+
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d'));
5267

53-
assert.strictEqual(runner.succeeded, true);
54-
assert.strictEqual(runner.invokedToolCount, 0);
55-
assert(runner.stdOutContained('loc_mock_successGetUnityEditorVersion 2022.3.49f1, revision=4dae1bb8668d, alpha=false, beta=false'));
56-
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersion;isOutput=false;issecret=false;]2022.3.49f1'));
57-
assert(runner.stdOutContained('##vso[task.setvariable variable=projectVersionRevision;isOutput=false;issecret=false;]4dae1bb8668d'));
68+
done();
69+
});
5870
})
5971
})

0 commit comments

Comments
 (0)