Skip to content

Commit 9381885

Browse files
authored
Merge pull request #287 from grine4ka/bugfix/typo-in-gitlab-pipeline-status
Fix typo in GitLab Pipeline status name
2 parents 6845294 + 672a4a1 commit 9381885

File tree

4 files changed

+183
-1
lines changed

4 files changed

+183
-1
lines changed

danger-kotlin-library/src/main/kotlin/systems/danger/kotlin/models/gitlab/GitLab.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ data class GitLabPipeline(
181181

182182
@Serializable
183183
enum class GitLabPipelineStatus {
184-
@SerialName("cancelled")
184+
@SerialName("canceled")
185185
CANCELLED,
186186

187187
@SerialName("failed")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package systems.danger.kotlin.models.gitlab
2+
3+
import kotlinx.serialization.decodeFromString
4+
import org.junit.Assert.assertEquals
5+
import org.junit.Test
6+
import systems.danger.kotlin.models.danger.DSL
7+
import systems.danger.kotlin.utils.TestUtils
8+
import systems.danger.kotlin.utils.TestUtils.JSONFiles
9+
10+
class GitLabPipelineStatusTest {
11+
12+
@Test
13+
fun testItParsesGitLabCancelledPipeline() {
14+
val dsl: DSL = TestUtils.Json.decodeFromString(JSONFiles.gitlabWithCancelledPipelineJSON)
15+
val gitLab = dsl.danger.gitlab
16+
assertEquals(GitLabPipelineStatus.CANCELLED, gitLab.mergeRequest.pipeline.status)
17+
}
18+
}

danger-kotlin-library/src/test/kotlin/systems/danger/kotlin/utils/TestUtils.kt

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ object TestUtils {
3636
loadJSON("gitlabDangerJSON.json")
3737
}
3838

39+
val gitlabWithCancelledPipelineJSON by lazy {
40+
loadJSON("gitlabWithCancelledPipelineDangerJSON.json")
41+
}
42+
3943
private fun loadJSON(named: String): String {
4044
return this.javaClass.classLoader.getResource(named).readText()
4145
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
{
2+
"danger": {
3+
"git": {
4+
"modified_files": [
5+
"static/source/swift/guides/getting_started.html.slim"
6+
],
7+
"created_files": [],
8+
"deleted_files": [],
9+
"commits": [
10+
{
11+
"sha": "621bc3348549e51c5bd6ea9f094913e9e4667c7b",
12+
"author": {
13+
"name": "Franco Meloni",
14+
"email": "[email protected]",
15+
"date": "2019-04-10T21:56:43.000Z"
16+
},
17+
"committer": {
18+
"name": "Franco Meloni",
19+
"email": "[email protected]",
20+
"date": "2019-04-10T21:56:43.000Z"
21+
},
22+
"message": "Update getting_started.html.slim",
23+
"parents": [],
24+
"url": "https://gitlab.com/danger-systems/danger.systems/commit/621bc3348549e51c5bd6ea9f094913e9e4667c7b",
25+
"tree": null
26+
}
27+
]
28+
},
29+
"gitlab": {
30+
"metadata": {
31+
"pullRequestID": "182",
32+
"repoSlug": "danger-systems/danger.systems"
33+
},
34+
"mr": {
35+
"id": 27469633,
36+
"iid": 182,
37+
"project_id": 1620437,
38+
"title": "Update getting_started.html.slim",
39+
"description": "Updating it to avoid problems like https://github.com/danger/swift/issues/221",
40+
"state": "merged",
41+
"created_at": "2019-04-10T21:57:45.346Z",
42+
"updated_at": "2019-04-11T00:37:22.460Z",
43+
"merged_by": {
44+
"id": 377669,
45+
"name": "Orta",
46+
"username": "orta",
47+
"state": "active",
48+
"avatar_url": "https://secure.gravatar.com/avatar/f116cb3be23153ec08b94e8bd4dbcfeb?s=80&d=identicon",
49+
"web_url": "https://gitlab.com/orta"
50+
},
51+
"merged_at": "2019-04-11T00:37:22.492Z",
52+
"closed_by": null,
53+
"closed_at": null,
54+
"target_branch": "master",
55+
"source_branch": "patch-2",
56+
"user_notes_count": 0,
57+
"upvotes": 0,
58+
"downvotes": 0,
59+
"assignee": {
60+
"id": 377669,
61+
"name": "Orta",
62+
"username": "orta",
63+
"state": "active",
64+
"avatar_url": "https://secure.gravatar.com/avatar/f116cb3be23153ec08b94e8bd4dbcfeb?s=80&d=identicon",
65+
"web_url": "https://gitlab.com/orta"
66+
},
67+
"author": {
68+
"id": 3331525,
69+
"name": "Franco Meloni",
70+
"username": "f-meloni",
71+
"state": "active",
72+
"avatar_url": "https://secure.gravatar.com/avatar/3d90e967de2beab6d44cfadbb4976b87?s=80&d=identicon",
73+
"web_url": "https://gitlab.com/f-meloni"
74+
},
75+
"assignees": [],
76+
"source_project_id": 10132593,
77+
"target_project_id": 1620437,
78+
"labels": [],
79+
"work_in_progress": false,
80+
"milestone": {
81+
"id": 1,
82+
"iid": 2,
83+
"project_id": 1000,
84+
"title": "Test Milestone",
85+
"description": "Test Description",
86+
"state": "closed",
87+
"start_date": "2019-04-10T21:57:45.346Z",
88+
"created_at": "2019-04-10T21:57:45.346Z",
89+
"updated_at": "2019-04-10T21:57:45.346Z",
90+
"due_date": "2019-06-10T00:00:00.000Z",
91+
"web_url": "https://gitlab.com/milestone"
92+
},
93+
"merge_when_pipeline_succeeds": false,
94+
"merge_status": "can_be_merged",
95+
"sha": "621bc3348549e51c5bd6ea9f094913e9e4667c7b",
96+
"merge_commit_sha": "377a24fb7a0f30364f089f7bca67752a8b61f477",
97+
"discussion_locked": null,
98+
"should_remove_source_branch": null,
99+
"force_remove_source_branch": true,
100+
"allow_collaboration": false,
101+
"allow_maintainer_to_push": false,
102+
"reference": "!182",
103+
"web_url": "https://gitlab.com/danger-systems/danger.systems/merge_requests/182",
104+
"time_stats": {
105+
"time_estimate": 0,
106+
"total_time_spent": 0,
107+
"human_time_estimate": null,
108+
"human_total_time_spent": null
109+
},
110+
"squash": false,
111+
"subscribed": false,
112+
"changes_count": "1",
113+
"latest_build_started_at": "2021-04-30T14:35:00.103+02:00",
114+
"latest_build_finished_at": "2019-04-11T00:33:22.492Z",
115+
"first_deployed_to_production_at": "2019-04-11T00:30:22.492Z",
116+
"pipeline": {
117+
"id": 50,
118+
"sha": "621bc3348549e51c5bd6ea9f094913e9e4667c7b",
119+
"ref": "ef28580bb2a00d985bffe4a4ce3fe09fdb12283f",
120+
"status": "canceled",
121+
"web_url": "https://gitlab.com/danger-systems/danger.systems/pipeline/621bc3348549e51c5bd6ea9f094913e9e4667c7b"
122+
},
123+
"head_pipeline": null,
124+
"diff_refs": {
125+
"base_sha": "ef28580bb2a00d985bffe4a4ce3fe09fdb12283f",
126+
"head_sha": "621bc3348549e51c5bd6ea9f094913e9e4667c7b",
127+
"start_sha": "ef28580bb2a00d985bffe4a4ce3fe09fdb12283f"
128+
},
129+
"merge_error": null,
130+
"user": {
131+
"can_merge": false
132+
},
133+
"approvals_before_merge": 1
134+
},
135+
"commits": [
136+
{
137+
"id": "621bc3348549e51c5bd6ea9f094913e9e4667c7b",
138+
"short_id": "621bc334",
139+
"created_at": "2019-04-10T21:56:43.000Z",
140+
"parent_ids": [],
141+
"title": "Update getting_started.html.slim",
142+
"message": "Update getting_started.html.slim",
143+
"author_name": "Franco Meloni",
144+
"author_email": "[email protected]",
145+
"authored_date": "2019-04-10T21:56:43.000Z",
146+
"committer_name": "Franco Meloni",
147+
"committer_email": "[email protected]",
148+
"committed_date": "2019-04-10T21:56:43.000Z"
149+
}
150+
]
151+
},
152+
"settings": {
153+
"github": {
154+
"accessToken": "NO_T...",
155+
"additionalHeaders": {}
156+
},
157+
"cliArgs": {}
158+
}
159+
}
160+
}

0 commit comments

Comments
 (0)