Skip to content

Commit dca03d2

Browse files
committed
test: use fixture for repo labels
1 parent cc97284 commit dca03d2

File tree

4 files changed

+118
-13
lines changed

4 files changed

+118
-13
lines changed

__tests__/fixtures/repoLabels.json

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
[
2+
{
3+
"name": ":bell: automerge",
4+
"color": "8f4fbc",
5+
"description": ""
6+
},
7+
{
8+
"name": ":bug: bug",
9+
"color": "b60205",
10+
"description": ""
11+
},
12+
{
13+
"name": ":bulb: feature request",
14+
"color": "0e8a16",
15+
"description": ""
16+
},
17+
{
18+
"name": ":busts_in_silhouette: duplicate",
19+
"color": "cccccc",
20+
"description": ""
21+
},
22+
{
23+
"name": ":coffin: wontfix",
24+
"color": "ffffff",
25+
"description": ""
26+
},
27+
{
28+
"name": ":eyes: upstream",
29+
"color": "fbca04",
30+
"description": ""
31+
},
32+
{
33+
"name": ":game_die: dependencies",
34+
"color": "0366d6",
35+
"description": ""
36+
},
37+
{
38+
"name": ":hatching_chick: good first issue",
39+
"color": "7057ff",
40+
"description": ""
41+
},
42+
{
43+
"name": ":mag: investigate",
44+
"color": "e6625b",
45+
"description": ""
46+
},
47+
{
48+
"name": ":mega: feedback",
49+
"color": "03a9f4",
50+
"description": ""
51+
},
52+
{
53+
"name": ":memo: documentation",
54+
"color": "c5def5",
55+
"description": ""
56+
},
57+
{
58+
"name": ":no_entry_sign: invalid",
59+
"color": "e6e6e6",
60+
"description": ""
61+
},
62+
{
63+
"name": ":pray: help wanted",
64+
"color": "4caf50",
65+
"description": ""
66+
},
67+
{
68+
"name": ":pushpin: pinned",
69+
"color": "28008e",
70+
"description": ""
71+
},
72+
{
73+
"name": ":question: question",
74+
"color": "3f51b5",
75+
"description": ""
76+
},
77+
{
78+
"name": ":robot: bot",
79+
"color": "69cde9",
80+
"description": ""
81+
},
82+
{
83+
"name": ":rocket: future maybe",
84+
"color": "fef2c0",
85+
"description": ""
86+
},
87+
{
88+
"name": ":skull: stale",
89+
"color": "237da0",
90+
"description": ""
91+
},
92+
{
93+
"name": ":sparkles: enhancement",
94+
"color": "0054ca",
95+
"description": ""
96+
},
97+
{
98+
"name": ":sparkling_heart: sponsor",
99+
"color": "fedbf0",
100+
"description": ""
101+
},
102+
{
103+
"name": ":thinking: needs more info",
104+
"color": "795548",
105+
"description": ""
106+
}
107+
]

__tests__/labeler.test.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import {describe, expect, test} from '@jest/globals';
1+
import {describe, expect, jest, test} from '@jest/globals';
22
import {Inputs} from '../src/context';
3-
import {Labeler, LabelStatus} from '../src/labeler';
3+
import {Label, Labeler, LabelStatus} from '../src/labeler';
4+
5+
import repoLabels from './fixtures/repoLabels.json';
6+
jest.spyOn(Labeler.prototype as any, 'getRepoLabels').mockImplementation((): Promise<Label[]> => {
7+
return <Promise<Label[]>>(repoLabels as unknown);
8+
});
49

510
const cases = [
611
[
712
'labels.update.yml',
813
{
9-
githubToken: process.env.GITHUB_TOKEN || '',
14+
githubToken: 'n/a',
1015
yamlFile: './__tests__/fixtures/labels.update.yml',
1116
skipDelete: true,
1217
dryRun: true,
@@ -25,7 +30,7 @@ const cases = [
2530
[
2631
'labels.exclude1.yml',
2732
{
28-
githubToken: process.env.GITHUB_TOKEN || '',
33+
githubToken: 'n/a',
2934
yamlFile: './__tests__/fixtures/labels.exclude1.yml',
3035
skipDelete: true,
3136
dryRun: true,
@@ -44,7 +49,7 @@ const cases = [
4449
[
4550
'labels.exclude2.yml',
4651
{
47-
githubToken: process.env.GITHUB_TOKEN || '',
52+
githubToken: 'n/a',
4853
yamlFile: './__tests__/fixtures/labels.exclude2.yml',
4954
skipDelete: true,
5055
dryRun: true,

dev.Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ ARG GITHUB_REPOSITORY
7272
RUN --mount=type=bind,target=.,rw \
7373
--mount=type=cache,target=/src/.yarn/cache \
7474
--mount=type=cache,target=/src/node_modules \
75-
--mount=type=secret,id=GITHUB_TOKEN \
76-
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test --coverageDirectory=/tmp/coverage
75+
yarn run test --coverageDirectory=/tmp/coverage
7776

7877
FROM scratch AS test-coverage
7978
COPY --from=test /tmp/coverage /

docker-bake.hcl

-6
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,4 @@ target "test" {
5757
}
5858
target = "test-coverage"
5959
output = ["./coverage"]
60-
secret = ["id=GITHUB_TOKEN,env=GITHUB_TOKEN"]
61-
}
62-
63-
target "test-local" {
64-
inherits = ["test"]
65-
secret = ["id=GITHUB_TOKEN,src=.dev/.ghtoken"]
6660
}

0 commit comments

Comments
 (0)