Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1616 from robbydyer/pl_event_failure_reason
Browse files Browse the repository at this point in the history
Add failure_reason to PipelineEvent Builds
  • Loading branch information
svanharmelen authored Jan 6, 2023
2 parents 8e0ac45 + 57255c8 commit 1c9b5e4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions event_webhook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ type PipelineEvent struct {
FinishedAt string `json:"finished_at"`
Duration float64 `json:"duration"`
QueuedDuration float64 `json:"queued_duration"`
FailureReason string `json:"failure_reason"`
When string `json:"when"`
Manual bool `json:"manual"`
AllowFailure bool `json:"allow_failure"`
Expand Down
20 changes: 8 additions & 12 deletions event_webhook_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestBuildEventUnmarshal(t *testing.T) {

var event *BuildEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Build Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -70,7 +69,6 @@ func TestDeploymentEventUnmarshal(t *testing.T) {

var event *DeploymentEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Deployment Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -105,7 +103,6 @@ func TestIssueCommentEventUnmarshal(t *testing.T) {

var event *IssueCommentEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Issue Comment Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -167,7 +164,6 @@ func TestIssueEventUnmarshal(t *testing.T) {

var event *IssueEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Issue Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -252,7 +248,6 @@ func TestMergeEventUnmarshal(t *testing.T) {

var event *MergeEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Merge Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -393,7 +388,6 @@ func TestMemberEventUnmarshal(t *testing.T) {

var event *MemberEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Member Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -463,7 +457,6 @@ func TestMergeEventUnmarshalFromGroup(t *testing.T) {

var event *MergeEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Group Merge Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -522,7 +515,6 @@ func TestPipelineEventUnmarshal(t *testing.T) {

var event *PipelineEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Pipeline Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -582,13 +574,20 @@ func TestPipelineEventUnmarshal(t *testing.T) {
if event.Builds[0].QueuedDuration != 3.5 {
t.Errorf("Builds[0].QueuedDuration is %v, want %v", event.Builds[0].QueuedDuration, 3.5)
}

if event.Builds[0].FailureReason != "script_failure" {
t.Errorf("Builds[0].Failurereason is %v, want %v", event.Builds[0].FailureReason, "script_failure")
}

if event.Builds[1].FailureReason != "" {
t.Errorf("Builds[0].Failurereason is %v, want %v", event.Builds[0].FailureReason, "''")
}
}

func TestPushEventUnmarshal(t *testing.T) {
jsonObject := loadFixture("testdata/webhooks/push.json")
var event *PushEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Push Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -627,7 +626,6 @@ func TestReleaseEventUnmarshal(t *testing.T) {

var event *ReleaseEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Release Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -670,7 +668,6 @@ func TestSubGroupEventUnmarshal(t *testing.T) {

var event *SubGroupEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("SubGroup Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down Expand Up @@ -700,7 +697,6 @@ func TestTagEventUnmarshal(t *testing.T) {
jsonObject := loadFixture("testdata/webhooks/tag_push.json")
var event *TagEvent
err := json.Unmarshal(jsonObject, &event)

if err != nil {
t.Errorf("Tag Event can not unmarshaled: %v\n ", err.Error())
}
Expand Down
13 changes: 11 additions & 2 deletions testdata/webhooks/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"source": "merge_request_event",
"status": "success",
"detailed_status": "passed",
"stages": ["build", "test", "deploy"],
"stages": [
"build",
"test",
"deploy"
],
"created_at": "2016-08-12 15:23:28 UTC",
"finished_at": "2016-08-12 15:26:29 UTC",
"duration": 63,
Expand Down Expand Up @@ -77,6 +81,7 @@
"when": "manual",
"manual": true,
"allow_failure": true,
"failure_reason": "script_failure",
"user": {
"id": 42,
"name": "User1",
Expand All @@ -90,7 +95,10 @@
"runner_type": "instance_type",
"active": true,
"is_shared": true,
"tags": ["docker", "gce"]
"tags": [
"docker",
"gce"
]
},
"artifacts_file": {
"filename": null,
Expand Down Expand Up @@ -223,3 +231,4 @@
}
]
}

0 comments on commit 1c9b5e4

Please sign in to comment.