-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathresolveUses.test.ts
87 lines (72 loc) · 2.03 KB
/
resolveUses.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { describe, expect, it } from "vitest";
import { resolveUses } from "./resolveUses.js";
describe(resolveUses, () => {
it("returns action@version when workflowsVersions is undefined", () => {
const actual = resolveUses("test-action", "v1.2.3");
expect(actual).toBe("[email protected]");
});
it("returns action@version when workflowsVersions does not contain the action", () => {
const actual = resolveUses("test-action", "v1.2.3", { other: {} });
expect(actual).toBe("[email protected]");
});
it("uses the provided version when it is greater than all the action versions in workflowsVersions", () => {
const actual = resolveUses("test-action", "v1.2.3", {
"test-action": {
"v0.1.2": {
pinned: true,
},
"v1.1.4": {
pinned: true,
},
},
});
expect(actual).toBe("[email protected]");
});
it("prefers a provided valid semver version when an action also has a non-semver tag", () => {
const actual = resolveUses("test-action", "v1.2.3", {
"test-action": {
main: {
pinned: true,
},
},
});
expect(actual).toBe("[email protected]");
});
it("prefers an action's semver tag when the provided version is a non-semver tag", () => {
const actual = resolveUses("test-action", "main", {
"test-action": {
"v1.2.3": {
pinned: true,
},
},
});
expect(actual).toBe("[email protected]");
});
it("uses the greatest version when the provided version is not bigger than all the action versions in workflowsVersions", () => {
const actual = resolveUses("test-action", "v1.2.3", {
"test-action": {
"v0.1.2": {
pinned: true,
},
"v1.3.5": {
pinned: true,
},
},
});
expect(actual).toBe("[email protected]");
});
it("uses a pinned hash when the greatest version contains a hash", () => {
const actual = resolveUses("test-action", "v1.2.3", {
"test-action": {
"v0.1.2": {
pinned: true,
},
"v1.3.5": {
hash: "abc",
pinned: true,
},
},
});
expect(actual).toBe("test-action@abc # v1.3.5");
});
});