Skip to content

Commit

Permalink
Merge pull request #1685 from smit-modi/deployment-event
Browse files Browse the repository at this point in the history
Added missing fields in DeploymentEvent
  • Loading branch information
svanharmelen committed Apr 10, 2023
2 parents d7398d8 + 3932683 commit 04bb121
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
16 changes: 10 additions & 6 deletions event_webhook_types.go
Expand Up @@ -143,12 +143,16 @@ type CommitCommentEvent struct {
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#deployment-events
type DeploymentEvent struct {
ObjectKind string `json:"object_kind"`
Status string `json:"status"`
DeployableID int `json:"deployable_id"`
DeployableURL string `json:"deployable_url"`
Environment string `json:"environment"`
Project struct {
ObjectKind string `json:"object_kind"`
Status string `json:"status"`
StatusChangedAt string `json:"status_changed_at"`
DeploymentID int `json:"deployment_id"`
DeployableID int `json:"deployable_id"`
DeployableURL string `json:"deployable_url"`
Environment string `json:"environment"`
EnvironmentSlug string `json:"environment_slug"`
EnvironmentExternalURL string `json:"environment_external_url"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Expand Down
16 changes: 16 additions & 0 deletions event_webhook_types_test.go
Expand Up @@ -174,6 +174,22 @@ func TestDeploymentEventUnmarshal(t *testing.T) {
if event.Ref != "1.0.0" {
t.Errorf("Ref is %s, want %s", event.Ref, "1.0.0")
}

if event.StatusChangedAt != "2021-04-28 21:50:00 +0200" {
t.Errorf("StatusChangedAt is %s, want %s", event.StatusChangedAt, "2021-04-28 21:50:00 +0200")
}

if event.DeploymentID != 15 {
t.Errorf("DeploymentID is %d, want %d", event.DeploymentID, 15)
}

if event.EnvironmentSlug != "staging" {
t.Errorf("EnvironmentSlug is %s, want %s", event.EnvironmentSlug, "staging")
}

if event.EnvironmentExternalURL != "https://staging.example.com" {
t.Errorf("EnvironmentExternalURL is %s, want %s", event.EnvironmentExternalURL, "https://staging.example.com")
}
}

func TestIssueCommentEventUnmarshal(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions testdata/webhooks/deployment.json
@@ -1,9 +1,13 @@
{
"object_kind": "deployment",
"status": "success",
"status_changed_at":"2021-04-28 21:50:00 +0200",
"deployment_id": 15,
"deployable_id": 796,
"deployable_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/jobs/796",
"environment": "staging",
"environment_slug": "staging",
"environment_external_url": "https://staging.example.com",
"project": {
"id": 30,
"name": "test-deployment-webhooks",
Expand Down

0 comments on commit 04bb121

Please sign in to comment.