Commit 9c5f26ed authored by Romain Maneschi's avatar Romain Maneschi

updatedById is not an array of int but an object like other fields

parent 4baaa27b
......@@ -3,6 +3,7 @@ package gitlab
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
......@@ -260,8 +261,14 @@ func TestParseIssueHook(t *testing.T) {
"group_id": 41
}],
"changes": {
"updated_by_id": [null, 1],
"updated_at": ["2017-09-15 16:50:55 UTC", "2017-09-15 16:52:00 UTC"],
"updated_by_id": {
"previous": null,
"current": 1
},
"updated_at": {
"previous": "2017-09-15 16:50:55 UTC",
"current": "2017-09-15 16:52:00 UTC"
},
"labels": {
"previous": [{
"id": 206,
......@@ -317,7 +324,8 @@ func TestParseIssueHook(t *testing.T) {
t.Errorf("Assignee username is %v, want %v", event.Assignee.Username, "user1")
}
assert.Equal(t, 1, len(event.Labels))
assert.Equal(t, []int{0, 1}, event.Changes.UpdatedByID)
assert.Equal(t, 0, event.Changes.UpdatedByID.Previous)
assert.Equal(t, 1, event.Changes.UpdatedByID.Current)
assert.Equal(t, 1, len(event.Changes.Labels.Previous))
assert.Equal(t, 1, len(event.Changes.Labels.Current))
}
......@@ -855,8 +863,14 @@ func TestParseMergeRequestHook(t *testing.T) {
"group_id": 41
}],
"changes": {
"updated_by_id": [null, 1],
"updated_at": ["2017-09-15 16:50:55 UTC", "2017-09-15 16:52:00 UTC"],
"updated_by_id": {
"previous": null,
"current": 1
},
"updated_at": {
"previous": "2017-09-15 16:50:55 UTC",
"current": "2017-09-15 16:52:00 UTC"
},
"labels": {
"previous": [{
"id": 206,
......@@ -912,7 +926,8 @@ func TestParseMergeRequestHook(t *testing.T) {
t.Errorf("WorkInProgress is %v, want %v", event.ObjectAttributes.WorkInProgress, false)
}
assert.Equal(t, 1, len(event.Labels))
assert.Equal(t, []int{0, 1}, event.Changes.UpdatedByID)
assert.Equal(t, 0, event.Changes.UpdatedByID.Previous)
assert.Equal(t, 1, event.Changes.UpdatedByID.Current)
assert.Equal(t, 1, len(event.Changes.Labels.Previous))
assert.Equal(t, 1, len(event.Changes.Labels.Current))
}
......
......@@ -173,7 +173,10 @@ type IssueEvent struct {
Previous []Label `json:"previous"`
Current []Label `json:"current"`
} `json:"labels"`
UpdatedByID []int `json:"updated_by_id"`
UpdatedByID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
} `json:"changes"`
}
......@@ -584,7 +587,10 @@ type MergeEvent struct {
Previous []Label `json:"previous"`
Current []Label `json:"current"`
} `json:"labels"`
UpdatedByID []int `json:"updated_by_id"`
UpdatedByID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
} `json:"changes"`
}
......
......@@ -214,8 +214,14 @@ func TestMergeEventUnmarshal(t *testing.T) {
"group_id": 41
}],
"changes": {
"updated_by_id": [null, 1],
"updated_at": ["2017-09-15 16:50:55 UTC", "2017-09-15 16:52:00 UTC"],
"updated_by_id": {
"previous": null,
"current": 1
},
"updated_at": {
"previous": "2017-09-15 16:50:55 UTC",
"current": "2017-09-15 16:52:00 UTC"
},
"labels": {
"previous": [{
"id": 206,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment