Skip to content

Commit

Permalink
Merge pull request #1699 from smit-modi/push-event
Browse files Browse the repository at this point in the history
Added EventName and Project.ID in PushEvent
  • Loading branch information
svanharmelen committed Apr 13, 2023
2 parents 7b93c5c + a3b9d49 commit 4c4f55d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions event_webhook_types.go
Expand Up @@ -812,6 +812,7 @@ type PipelineEvent struct {
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#push-events
type PushEvent struct {
ObjectKind string `json:"object_kind"`
EventName string `json:"event_name"`
Before string `json:"before"`
After string `json:"after"`
Ref string `json:"ref"`
Expand All @@ -823,6 +824,7 @@ type PushEvent struct {
UserAvatar string `json:"user_avatar"`
ProjectID int `json:"project_id"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
Expand Down
8 changes: 8 additions & 0 deletions event_webhook_types_test.go
Expand Up @@ -725,6 +725,10 @@ func TestPushEventUnmarshal(t *testing.T) {
t.Errorf("Push Event is null")
}

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

if event.ProjectID != 15 {
t.Errorf("ProjectID is %v, want %v", event.ProjectID, 15)
}
Expand All @@ -733,6 +737,10 @@ func TestPushEventUnmarshal(t *testing.T) {
t.Errorf("Username is %s, want %s", event.UserName, exampleEventUserName)
}

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

if event.Commits[0] == nil || event.Commits[0].Timestamp == nil {
t.Errorf("Commit Timestamp isn't nil")
}
Expand Down
1 change: 1 addition & 0 deletions testdata/webhooks/push.json
@@ -1,5 +1,6 @@
{
"object_kind": "push",
"event_name": "push",
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master",
Expand Down

0 comments on commit 4c4f55d

Please sign in to comment.