Skip to content

Commit

Permalink
Updated fields in MergeEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
smit-modi committed Apr 12, 2023
1 parent a81370b commit fad749a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
11 changes: 6 additions & 5 deletions event_webhook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,15 @@ type MergeEvent struct {
WorkInProgress bool `json:"work_in_progress"`
TotalTimeSpent int `json:"total_time_spent"`
TimeChange int `json:"time_change"`
HumanTotalTimeSpent int `json:"human_total_time_spent"`
HumanTimeChange int `json:"human_time_change"`
HumanTimeEstimate int `json:"human_time_estimate"`
Labels []*EventLabel `json:"labels"`
HumanTotalTimeSpent string `json:"human_total_time_spent"`
HumanTimeChange string `json:"human_time_change"`
HumanTimeEstimate string `json:"human_time_estimate"`
FirstContribution bool `json:"first_contribution"`
DetailedMergeStatus string `json:"detailed_merge_status"`
URL string `json:"url"`
Labels []*EventLabel `json:"labels"`
Action string `json:"action"`
DetailedMergeStatus string `json:"detailed_merge_status"`
OldRev string `json:"oldrev"`
} `json:"object_attributes"`
Repository *Repository `json:"repository"`
Labels []*EventLabel `json:"labels"`
Expand Down
33 changes: 29 additions & 4 deletions event_webhook_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ func TestMergeEventUnmarshal(t *testing.T) {
t.Errorf("Merge Event is null")
}

if event.EventType != "merge_request" {
t.Errorf("EventType is %v, want %v", event.EventType, "merge_request")
}

if event.Project.CIConfigPath != "" {
t.Errorf("Project.CIConfigPath is %v, want %v", event.Project.CIConfigPath, "")
}

if event.ObjectAttributes.ID != 99 {
t.Errorf("ObjectAttributes.ID is %v, want %v", event.ObjectAttributes.ID, 99)
}
Expand All @@ -361,6 +369,27 @@ func TestMergeEventUnmarshal(t *testing.T) {
if event.ObjectAttributes.LastCommit.ID != "da1560886d4f094c3e6c9ef40349f7d38b5d27d7" {
t.Errorf("ObjectAttributes.LastCommit.ID is %v, want %s", event.ObjectAttributes.LastCommit.ID, "da1560886d4f094c3e6c9ef40349f7d38b5d27d7")
}

if event.ObjectAttributes.TotalTimeSpent != 0 {
t.Errorf("ObjectAttributes.TotalTimeSpent is %v, want %v", event.ObjectAttributes.TotalTimeSpent, 0)
}

if event.ObjectAttributes.TimeChange != 0 {
t.Errorf("ObjectAttributes.TimeChange is %v, want %v", event.ObjectAttributes.TimeChange, 0)
}

if event.ObjectAttributes.HumanTotalTimeSpent != "30m" {
t.Errorf("ObjectAttributes.HumanTotalTimeSpent is %v, want %v", event.ObjectAttributes.HumanTotalTimeSpent, "30m")
}

if event.ObjectAttributes.HumanTimeChange != "30m" {
t.Errorf("ObjectAttributes.HumanTimeChange is %v, want %v", event.ObjectAttributes.HumanTimeChange, "30m")
}

if event.ObjectAttributes.HumanTimeEstimate != "30m" {
t.Errorf("ObjectAttributes.HumanTimeEstimate is %v, want %v", event.ObjectAttributes.HumanTimeEstimate, "30m")
}

if event.Assignees[0].Name != expectedName {
t.Errorf("Assignee.Name is %v, want %v", event.Assignees[0].Name, expectedName)
}
Expand Down Expand Up @@ -610,10 +639,6 @@ func TestMergeEventUnmarshalFromGroup(t *testing.T) {
t.Errorf("Repository.Name is %v, want %v", event.Repository.Name, exampleProjectName)
}

if event.Assignee.Username != expectedUsername {
t.Errorf("Assignee.Username is %v, want %v", event.Assignee, expectedUsername)
}

if event.User.Name != expectedName {
t.Errorf("Username is %s, want %s", event.User.Name, expectedName)
}
Expand Down
9 changes: 9 additions & 0 deletions testdata/webhooks/merge_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,25 @@
"ssh_url":"git@example.com:awesome_space/awesome_project.git",
"http_url":"http://example.com/awesome_space/awesome_project.git"
},
"last_edited_at":"2023-03-27 00:03:05 UTC",
"last_edited_by_id": 51,
"state_id": 1,
"last_commit": {
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
"title": "MR Title",
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://example.com/awesome_space/awesome_project/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev@dv6700.(none)"
}
},
"total_time_spent": 0,
"time_change": 0,
"human_total_time_spent": "30m",
"human_time_change": "30m",
"human_time_estimate": "30m",
"labels": [{
"id": 206,
"title": "API",
Expand Down

0 comments on commit fad749a

Please sign in to comment.