Repository: xanzy/go-gitlab
Pull request #1152 (2021-05-25 18:35:10)

Assignees
The data used to find those out is from `gitlab.alpinelinux.org` (GitLab Community Edition 13.9.7)

```json
  "assignees": [
    {
      "id": 1589,
      "name": "Leo",
      "username": "Leo",
      "avatar_url": "https://gitlab.alpinelinux.org/uploads/-/system/user/avatar/1589/avatar.png",
      "email": "meme"
   }
  ]
```

maxice8: Seems like `User1` appears enough the linter wants it `const`
svanharmelen: If you rebase the linter should not complain anymore 🤞🏻 

Patch:
diff --git a/event_webhook_types.go b/event_webhook_types.go
index f59b831..fb89ade 100644
--- a/event_webhook_types.go
+++ b/event_webhook_types.go
@@ -530,27 +530,28 @@ type MergeEvent struct {
 				Email string `json:"email"`
 			} `json:"author"`
 		} `json:"last_commit"`
-		WorkInProgress bool          `json:"work_in_progress"`
-		URL            string        `json:"url"`
-		Action         string        `json:"action"`
-		OldRev         string        `json:"oldrev"`
-		Assignee       MergeAssignee `json:"assignee"`
+		WorkInProgress bool           `json:"work_in_progress"`
+		URL            string         `json:"url"`
+		Action         string         `json:"action"`
+		OldRev         string         `json:"oldrev"`
+		Assignee       *MergeAssignee `json:"assignee"`
 	} `json:"object_attributes"`
-	Repository *Repository   `json:"repository"`
-	Assignee   MergeAssignee `json:"assignee"`
-	Labels     []Label       `json:"labels"`
+	Repository *Repository      `json:"repository"`
+	Assignee   *MergeAssignee   `json:"assignee"`
+	Assignees  []*MergeAssignee `json:"assignees"`
+	Labels     []*Label         `json:"labels"`
 	Changes    struct {
 		Assignees struct {
-			Previous []MergeAssignee `json:"previous"`
-			Current  []MergeAssignee `json:"current"`
+			Previous []*MergeAssignee `json:"previous"`
+			Current  []*MergeAssignee `json:"current"`
 		} `json:"assignees"`
 		Description struct {
 			Previous string `json:"previous"`
 			Current  string `json:"current"`
 		} `json:"description"`
 		Labels struct {
-			Previous []Label `json:"previous"`
-			Current  []Label `json:"current"`
+			Previous []*Label `json:"previous"`
+			Current  []*Label `json:"current"`
 		} `json:"labels"`
 		SourceBranch struct {
 			Previous string `json:"previous"`
@@ -589,9 +590,11 @@ type MergeEvent struct {
 
 // MergeAssignee represents a merge assignee.
 type MergeAssignee struct {
+	ID        int    `json:"id"`
 	Name      string `json:"name"`
 	Username  string `json:"username"`
 	AvatarURL string `json:"avatar_url"`
+	Email     string `json:"email"`
 }
 
 // MergeParams represents the merge params.


Test patch:
diff --git a/event_webhook_types_test.go b/event_webhook_types_test.go
index 71b98f8..6d70b75 100644
--- a/event_webhook_types_test.go
+++ b/event_webhook_types_test.go
@@ -21,6 +21,11 @@ import (
 	"testing"
 )
 
+const (
+	expectedName     = "User1"
+	expectedUsername = "user1"
+)
+
 func TestBuildEventUnmarshal(t *testing.T) {
 	jsonObject := loadFixture("testdata/webhooks/build.json")
 
@@ -143,12 +148,12 @@ 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.Assignee.Name != "User1" {
-		t.Errorf("Assignee.Name is %v, want %v", event.ObjectAttributes.Assignee.Name, "User1")
+	if event.ObjectAttributes.Assignee.Name != expectedName {
+		t.Errorf("Assignee.Name is %v, want %v", event.ObjectAttributes.Assignee.Name, expectedName)
 	}
 
-	if event.ObjectAttributes.Assignee.Username != "user1" {
-		t.Errorf("ObjectAttributes is %v, want %v", event.ObjectAttributes.Assignee.Username, "user1")
+	if event.ObjectAttributes.Assignee.Username != expectedUsername {
+		t.Errorf("ObjectAttributes is %v, want %v", event.ObjectAttributes.Assignee.Username, expectedUsername)
 	}
 
 	if event.User.Name != "Administrator" {
@@ -162,6 +167,18 @@ func TestMergeEventUnmarshal(t *testing.T) {
 	if name := event.ObjectAttributes.LastCommit.Author.Name; name != "GitLab dev user" {
 		t.Errorf("Commit Username is %s, want %s", name, "GitLab dev user")
 	}
+
+	if event.Assignees[0].ID != 1 {
+		t.Errorf("Assignees[0].ID is %v, want %v", event.Assignees[0].ID, 1)
+	}
+
+	if event.Assignees[0].Name != expectedName {
+		t.Errorf("Assignees[0].Name is %v, want %v", event.Assignees[0].Name, expectedName)
+	}
+
+	if event.Assignees[0].Username != expectedUsername {
+		t.Errorf("Assignees[0].Username is %v, want %v", event.Assignees[0].Username, expectedName)
+	}
 }
 
 func TestMergeEventUnmarshalFromGroup(t *testing.T) {
diff --git a/testdata/webhooks/merge_request.json b/testdata/webhooks/merge_request.json
index 6678953..e416f26 100644
--- a/testdata/webhooks/merge_request.json
+++ b/testdata/webhooks/merge_request.json
@@ -95,6 +95,14 @@
       "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
     }
   },
+  "assignees": [
+    {
+      "id": 1,
+      "name": "User1",
+      "username": "user1",
+      "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
+    }
+  ],
   "labels": [{
     "id": 206,
     "title": "API",