Skip to content

Commit cdf6f67

Browse files
committed
fix lint (use const for eventObjectKind)
1 parent 4e9851d commit cdf6f67

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

event_parsing.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ const (
5151
noteableTypeSnippet = "Snippet"
5252
)
5353

54+
const (
55+
eventObjectKindPush = "push"
56+
eventObjectKindTagPush = "tag_push"
57+
eventObjectKindMergeRequest = "merge_request"
58+
)
59+
5460
type noteEvent struct {
5561
ObjectKind string `json:"object_kind"`
5662
ObjectAttributes struct {
@@ -124,9 +130,9 @@ func ParseSystemhook(payload []byte) (event interface{}, err error) {
124130
}
125131

126132
switch e.EventName {
127-
case "push":
133+
case eventObjectKindPush:
128134
event = &PushSystemEvent{}
129-
case "tag_push":
135+
case eventObjectKindTagPush:
130136
event = &TagPushSystemEvent{}
131137
case "repository_update":
132138
event = &RepositoryUpdateSystemEvent{}
@@ -254,11 +260,11 @@ func ParseWebhook(eventType EventType, payload []byte) (event interface{}, err e
254260
return nil, err
255261
}
256262
switch service.ObjectKind {
257-
case "push":
263+
case eventObjectKindPush:
258264
event = &PushEvent{}
259-
case "tag_push":
265+
case eventObjectKindTagPush:
260266
event = &TagEvent{}
261-
case "merge_request":
267+
case eventObjectKindMergeRequest:
262268
event = &MergeEvent{}
263269
default:
264270
return nil, fmt.Errorf("unexpected service type %s", service.ObjectKind)

event_parsing_systemhook_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestParseSystemhookPush(t *testing.T) {
3434
if !ok {
3535
t.Errorf("Expected PushSystemHookEvent, but parsing produced %T", parsedEvent)
3636
}
37-
assert.Equal(t, "push", event.EventName)
37+
assert.Equal(t, eventObjectKindPush, event.EventName)
3838
}
3939

4040
func TestParseSystemhookTagPush(t *testing.T) {
@@ -49,7 +49,7 @@ func TestParseSystemhookTagPush(t *testing.T) {
4949
if !ok {
5050
t.Errorf("Expected TagPushSystemHookEvent, but parsing produced %T", parsedEvent)
5151
}
52-
assert.Equal(t, "tag_push", event.EventName)
52+
assert.Equal(t, eventObjectKindTagPush, event.EventName)
5353
}
5454

5555
func TestParseSystemhookMergeRequest(t *testing.T) {
@@ -64,7 +64,7 @@ func TestParseSystemhookMergeRequest(t *testing.T) {
6464
if !ok {
6565
t.Errorf("Expected MergeRequestSystemHookEvent, but parsing produced %T", parsedEvent)
6666
}
67-
assert.Equal(t, "merge_request", event.ObjectKind)
67+
assert.Equal(t, eventObjectKindMergeRequest, event.ObjectKind)
6868
}
6969

7070
func TestParseSystemhookRepositoryUpdate(t *testing.T) {

event_parsing_webhook_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ func TestParsePushHook(t *testing.T) {
287287
t.Errorf("Expected PushEvent, but parsing produced %T", parsedEvent)
288288
}
289289

290-
if event.ObjectKind != "push" {
291-
t.Errorf("ObjectKind is %v, want %v", event.ObjectKind, "push")
290+
if event.ObjectKind != eventObjectKindPush {
291+
t.Errorf("ObjectKind is %v, want %v", event.ObjectKind, eventObjectKindPush)
292292
}
293293

294294
if event.ProjectID != 15 {
@@ -373,8 +373,8 @@ func TestParseTagHook(t *testing.T) {
373373
t.Errorf("Expected TagEvent, but parsing produced %T", parsedEvent)
374374
}
375375

376-
if event.ObjectKind != "tag_push" {
377-
t.Errorf("ObjectKind is %v, want %v", event.ObjectKind, "tag_push")
376+
if event.ObjectKind != eventObjectKindTagPush {
377+
t.Errorf("ObjectKind is %v, want %v", event.ObjectKind, eventObjectKindTagPush)
378378
}
379379

380380
if event.ProjectID != 1 {

event_webhook_types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ func TestMergeEventUnmarshalFromGroup(t *testing.T) {
241241
t.Errorf("Group Merge Event is null")
242242
}
243243

244-
if event.ObjectKind != "merge_request" {
245-
t.Errorf("ObjectKind is %v, want %v", event.ObjectKind, "merge_request")
244+
if event.ObjectKind != eventObjectKindMergeRequest {
245+
t.Errorf("ObjectKind is %v, want %v", event.ObjectKind, eventObjectKindMergeRequest)
246246
}
247247

248248
if event.User.Username != expectedUsername {

0 commit comments

Comments
 (0)