Skip to content

Commit

Permalink
Updated IssueCommentEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
smit-modi committed Apr 10, 2023
1 parent 7b93c5c commit ba9a237
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions event_webhook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ type DeploymentEvent struct {
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-an-issue
type IssueCommentEvent struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
User *User `json:"user"`
ProjectID int `json:"project_id"`
Project struct {
Expand Down Expand Up @@ -246,6 +247,8 @@ type IssueCommentEvent struct {
HumanTimeEstimate string `json:"human_time_estimate"`
AssigneeIDs []int `json:"assignee_ids"`
AssigneeID int `json:"assignee_id"`
Position int `json:"position"`
BranchName string `json:"branch_name"`
} `json:"issue"`
}

Expand Down
12 changes: 12 additions & 0 deletions event_webhook_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func TestIssueCommentEventUnmarshal(t *testing.T) {
t.Errorf("ObjectKind is %v, want %v", event.ObjectKind, NoteEventTargetType)
}

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

if event.ProjectID != 5 {
t.Errorf("ProjectID is %v, want %v", event.ProjectID, 5)
}
Expand All @@ -221,6 +225,14 @@ func TestIssueCommentEventUnmarshal(t *testing.T) {
t.Errorf("Issue title is %v, want %v", event.Issue.Title, "test_issue")
}

if event.Issue.Position != 0 {
t.Errorf("Issue position is %v, want %v", event.Issue.Position, 0)
}

if event.Issue.BranchName != "" {
t.Errorf("Issue branch name is %v, want %v", event.Issue.BranchName, "")
}

if len(event.Issue.Labels) == 0 || event.Issue.Labels[0].ID != 25 {
t.Errorf("Label id is null")
}
Expand Down
1 change: 1 addition & 0 deletions testdata/webhooks/note_issue.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"object_kind": "note",
"event_type": "note",
"user": {
"id": 42,
"name": "User1",
Expand Down

0 comments on commit ba9a237

Please sign in to comment.