forked from danger/peril
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_github_runner-runs.test.ts
More file actions
134 lines (121 loc) · 2.97 KB
/
Copy path_github_runner-runs.test.ts
File metadata and controls
134 lines (121 loc) · 2.97 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import generateInstallation from "../../../testing/installationFactory"
import { GitHubRunSettings, runsForEvent } from "../github_runner"
// Default settings
const defaultRun: GitHubRunSettings = {
commentableID: 2,
eventID: "09876",
hasRelatedCommentable: true,
installationID: 123,
installationSettings: {
env_vars: [],
ignored_repos: [],
modules: [],
},
isRepoEvent: true,
isTriggeredByUser: true,
repoName: "danger/peril",
repoSpecificRules: {
pull_request: "pr.ts",
},
triggeredByUsername: "orta",
}
const defaultSettings = {
env_vars: [],
ignored_repos: [],
modules: [],
}
// A function to override defaults
const getSettings = (overwrites: Partial<GitHubRunSettings>) => ({
...defaultRun,
...overwrites,
})
it("handles a platform only run", () => {
const installation = generateInstallation({
iID: 12,
rules: {
pull_request: "orta/peril-dangerfiles@pr.ts",
},
settings: defaultSettings,
})
const settings = getSettings({ repoSpecificRules: {} })
const runs = runsForEvent("pull_request", "created", installation, {}, settings)
expect(runs).toEqual([
{
action: "created",
branch: "master",
dangerfilePath: "pr.ts",
dslType: 0,
event: "pull_request",
feedback: 0,
repoSlug: "orta/peril-dangerfiles",
referenceString: "orta/peril-dangerfiles@pr.ts",
},
])
})
it("gets the expected runs for platform + repo rules", () => {
const installation = generateInstallation({
iID: 12,
rules: {
pull_request: "orta/peril-dangerfiles@pr.ts",
},
settings: defaultSettings,
})
const settings = getSettings({})
const runs = runsForEvent("pull_request", "created", installation, {}, settings)
expect(runs).toEqual([
{
action: "created",
branch: "master",
dangerfilePath: "pr.ts",
dslType: 0,
event: "pull_request",
feedback: 0,
repoSlug: "orta/peril-dangerfiles",
referenceString: "orta/peril-dangerfiles@pr.ts",
},
{
action: "created",
branch: "master",
dangerfilePath: "pr.ts",
dslType: 0,
event: "pull_request",
feedback: 0,
repoSlug: undefined,
referenceString: "pr.ts",
},
])
})
it("gets the expected runs for platform", () => {
const installation = generateInstallation({
iID: 12,
rules: {
pull_request: "orta/peril-dangerfiles@pr.ts",
},
settings: defaultSettings,
})
const repo = {
fullName: "danger/peril",
id: 1,
installationID: 12,
rules: {
issues: "pr.ts",
},
}
const settings = getSettings({
repoSpecificRules: repo.rules,
repoName: repo.fullName,
})
const runs = runsForEvent("issues", "created", installation, {}, settings)
expect(runs).toEqual([
{
action: "created",
branch: "master",
dangerfilePath: "pr.ts",
dslType: 1,
event: "issues",
feedback: 0,
referenceString: "pr.ts",
repoSlug: undefined,
},
])
})