Skip to content

Commit

Permalink
Merge pull request #192 from crazy-max/fix-tests
Browse files Browse the repository at this point in the history
test: use fixture for repo labels
  • Loading branch information
crazy-max authored Sep 1, 2023
2 parents cc97284 + dca03d2 commit d4e5c01
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 13 deletions.
107 changes: 107 additions & 0 deletions __tests__/fixtures/repoLabels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[
{
"name": ":bell: automerge",
"color": "8f4fbc",
"description": ""
},
{
"name": ":bug: bug",
"color": "b60205",
"description": ""
},
{
"name": ":bulb: feature request",
"color": "0e8a16",
"description": ""
},
{
"name": ":busts_in_silhouette: duplicate",
"color": "cccccc",
"description": ""
},
{
"name": ":coffin: wontfix",
"color": "ffffff",
"description": ""
},
{
"name": ":eyes: upstream",
"color": "fbca04",
"description": ""
},
{
"name": ":game_die: dependencies",
"color": "0366d6",
"description": ""
},
{
"name": ":hatching_chick: good first issue",
"color": "7057ff",
"description": ""
},
{
"name": ":mag: investigate",
"color": "e6625b",
"description": ""
},
{
"name": ":mega: feedback",
"color": "03a9f4",
"description": ""
},
{
"name": ":memo: documentation",
"color": "c5def5",
"description": ""
},
{
"name": ":no_entry_sign: invalid",
"color": "e6e6e6",
"description": ""
},
{
"name": ":pray: help wanted",
"color": "4caf50",
"description": ""
},
{
"name": ":pushpin: pinned",
"color": "28008e",
"description": ""
},
{
"name": ":question: question",
"color": "3f51b5",
"description": ""
},
{
"name": ":robot: bot",
"color": "69cde9",
"description": ""
},
{
"name": ":rocket: future maybe",
"color": "fef2c0",
"description": ""
},
{
"name": ":skull: stale",
"color": "237da0",
"description": ""
},
{
"name": ":sparkles: enhancement",
"color": "0054ca",
"description": ""
},
{
"name": ":sparkling_heart: sponsor",
"color": "fedbf0",
"description": ""
},
{
"name": ":thinking: needs more info",
"color": "795548",
"description": ""
}
]
15 changes: 10 additions & 5 deletions __tests__/labeler.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import {describe, expect, test} from '@jest/globals';
import {describe, expect, jest, test} from '@jest/globals';
import {Inputs} from '../src/context';
import {Labeler, LabelStatus} from '../src/labeler';
import {Label, Labeler, LabelStatus} from '../src/labeler';

import repoLabels from './fixtures/repoLabels.json';
jest.spyOn(Labeler.prototype as any, 'getRepoLabels').mockImplementation((): Promise<Label[]> => {
return <Promise<Label[]>>(repoLabels as unknown);
});

const cases = [
[
'labels.update.yml',
{
githubToken: process.env.GITHUB_TOKEN || '',
githubToken: 'n/a',
yamlFile: './__tests__/fixtures/labels.update.yml',
skipDelete: true,
dryRun: true,
Expand All @@ -25,7 +30,7 @@ const cases = [
[
'labels.exclude1.yml',
{
githubToken: process.env.GITHUB_TOKEN || '',
githubToken: 'n/a',
yamlFile: './__tests__/fixtures/labels.exclude1.yml',
skipDelete: true,
dryRun: true,
Expand All @@ -44,7 +49,7 @@ const cases = [
[
'labels.exclude2.yml',
{
githubToken: process.env.GITHUB_TOKEN || '',
githubToken: 'n/a',
yamlFile: './__tests__/fixtures/labels.exclude2.yml',
skipDelete: true,
dryRun: true,
Expand Down
3 changes: 1 addition & 2 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ ARG GITHUB_REPOSITORY
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
--mount=type=secret,id=GITHUB_TOKEN \
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test --coverageDirectory=/tmp/coverage
yarn run test --coverageDirectory=/tmp/coverage

FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /
6 changes: 0 additions & 6 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,4 @@ target "test" {
}
target = "test-coverage"
output = ["./coverage"]
secret = ["id=GITHUB_TOKEN,env=GITHUB_TOKEN"]
}

target "test-local" {
inherits = ["test"]
secret = ["id=GITHUB_TOKEN,src=.dev/.ghtoken"]
}

0 comments on commit d4e5c01

Please sign in to comment.