Skip to content

Commit

Permalink
Merge pull request #1689 from smit-modi/issue-comment-event
Browse files Browse the repository at this point in the history
Updated IssueCommentEvent
  • Loading branch information
svanharmelen committed Apr 14, 2023
2 parents e7028c3 + f459ed3 commit 195295c
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 @@ -211,6 +211,7 @@ type FeatureFlagEvent 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 @@ -254,6 +255,8 @@ type IssueCommentEvent struct {
ProjectID int `json:"project_id"`
MilestoneID int `json:"milestone_id"`
AuthorID int `json:"author_id"`
Position int `json:"position"`
BranchName string `json:"branch_name"`
Description string `json:"description"`
State string `json:"state"`
Title string `json:"title"`
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 @@ -297,6 +297,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 @@ -313,6 +317,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 195295c

Please sign in to comment.