Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
0f869110
Commit
0f869110
authored
Dec 12, 2017
by
Reficul
Committed by
Sander van Harmelen
Dec 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix event structs (#274)
parent
d2fe6f36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
13 deletions
+97
-13
events.go
events.go
+52
-13
events_test.go
events_test.go
+45
-0
No files found.
events.go
View file @
0f869110
...
...
@@ -49,9 +49,21 @@ type PushEvent struct {
WebURL
string
`json:"web_url"`
Visibility
VisibilityValue
`json:"visibility"`
}
`json:"project"`
Repository
*
Repository
`json:"repository"`
Commits
[]
*
Commit
`json:"commits"`
TotalCommitsCount
int
`json:"total_commits_count"`
Repository
*
Repository
`json:"repository"`
Commits
[]
*
struct
{
ID
string
`json:"id"`
Message
string
`json:"message"`
Timestamp
*
time
.
Time
`json:"timestamp"`
URL
string
`json:"url"`
Author
struct
{
Name
string
`json:"name"`
Email
string
`json:"email"`
}
`json:"author"`
Added
[]
string
`json:"added"`
Modified
[]
string
`json:"modified"`
Removed
[]
string
`json:"removed"`
}
`json:"commits"`
TotalCommitsCount
int
`json:"total_commits_count"`
}
// TagEvent represents a tag event.
...
...
@@ -84,9 +96,21 @@ type TagEvent struct {
WebURL
string
`json:"web_url"`
Visibility
VisibilityValue
`json:"visibility"`
}
`json:"project"`
Repository
*
Repository
`json:"repository"`
Commits
[]
*
Commit
`json:"commits"`
TotalCommitsCount
int
`json:"total_commits_count"`
Repository
*
Repository
`json:"repository"`
Commits
[]
*
struct
{
ID
string
`json:"id"`
Message
string
`json:"message"`
Timestamp
*
time
.
Time
`json:"timestamp"`
URL
string
`json:"url"`
Author
struct
{
Name
string
`json:"name"`
Email
string
`json:"email"`
}
`json:"author"`
Added
[]
string
`json:"added"`
Modified
[]
string
`json:"modified"`
Removed
[]
string
`json:"removed"`
}
`json:"commits"`
TotalCommitsCount
int
`json:"total_commits_count"`
}
// IssueEvent represents a issue event.
...
...
@@ -186,7 +210,16 @@ type CommitCommentEvent struct {
DeletedFile
bool
`json:"deleted_file"`
}
`json:"st_diff"`
}
`json:"object_attributes"`
Commit
*
Commit
`json:"commit"`
Commit
*
struct
{
ID
string
`json:"id"`
Message
string
`json:"message"`
Timestamp
*
time
.
Time
`json:"timestamp"`
URL
string
`json:"url"`
Author
struct
{
Name
string
`json:"name"`
Email
string
`json:"email"`
}
`json:"author"`
}
`json:"commit"`
}
// MergeCommentEvent represents a comment on a merge event.
...
...
@@ -272,7 +305,10 @@ type MergeCommentEvent struct {
Message
string
`json:"message"`
Timestamp
*
time
.
Time
`json:"timestamp"`
URL
string
`json:"url"`
Author
*
Author
`json:"author"`
Author
struct
{
Name
string
`json:"name"`
Email
string
`json:"email"`
}
`json:"author"`
}
`json:"last_commit"`
WorkInProgress
bool
`json:"work_in_progress"`
TotalTimeSpent
int
`json:"total_time_spent"`
...
...
@@ -431,7 +467,10 @@ type MergeEvent struct {
Message
string
`json:"message"`
Timestamp
*
time
.
Time
`json:"timestamp"`
URL
string
`json:"url"`
Author
*
Author
`json:"author"`
Author
struct
{
Name
string
`json:"name"`
Email
string
`json:"email"`
}
`json:"author"`
}
`json:"last_commit"`
WorkInProgress
bool
`json:"work_in_progress"`
URL
string
`json:"url"`
...
...
@@ -531,10 +570,10 @@ type PipelineEvent struct {
Visibility
VisibilityValue
`json:"visibility"`
}
`json:"project"`
Commit
struct
{
ID
string
`json:"id"`
Message
string
`json:"message"`
Timestamp
time
.
Time
`json:"timestamp"`
URL
string
`json:"url"`
ID
string
`json:"id"`
Message
string
`json:"message"`
Timestamp
*
time
.
Time
`json:"timestamp"`
URL
string
`json:"url"`
Author
struct
{
Name
string
`json:"name"`
Email
string
`json:"email"`
...
...
events_test.go
View file @
0f869110
...
...
@@ -87,6 +87,17 @@ func TestPushEventUnmarshal(t *testing.T) {
t
.
Errorf
(
"ProjectID is %v, want %v"
,
event
.
ProjectID
,
15
)
}
if
event
.
UserName
!=
"John Smith"
{
t
.
Errorf
(
"Username is %s, want %s"
,
event
.
UserName
,
"John Smith"
)
}
if
event
.
Commits
[
0
]
==
nil
||
event
.
Commits
[
0
]
.
Timestamp
==
nil
{
t
.
Errorf
(
"Commit Timestamp isn't nil"
)
}
if
event
.
Commits
[
0
]
==
nil
||
event
.
Commits
[
0
]
.
Author
.
Name
!=
"Jordi Mallach"
{
t
.
Errorf
(
"Commit Username is %s, want %s"
,
event
.
UserName
,
"Jordi Mallach"
)
}
}
func
TestMergeEventUnmarshal
(
t
*
testing
.
T
)
{
...
...
@@ -199,6 +210,17 @@ func TestMergeEventUnmarshal(t *testing.T) {
t
.
Errorf
(
"ObjectAttributes is %v, want %v"
,
event
.
ObjectAttributes
.
Assignee
.
Username
,
"user1"
)
}
if
event
.
User
.
Name
==
""
{
t
.
Errorf
(
"Username is %s, want %s"
,
event
.
User
.
Name
,
"Administrator"
)
}
if
event
.
ObjectAttributes
.
LastCommit
.
Timestamp
==
nil
{
t
.
Errorf
(
"Timestamp isn't nil"
)
}
if
name
:=
event
.
ObjectAttributes
.
LastCommit
.
Author
.
Name
;
name
!=
"GitLab dev user"
{
t
.
Errorf
(
"Commit Username is %s, want %s"
,
name
,
"GitLab dev user"
)
}
}
func
TestPipelineEventUnmarshal
(
t
*
testing
.
T
)
{
...
...
@@ -376,6 +398,17 @@ func TestPipelineEventUnmarshal(t *testing.T) {
t
.
Errorf
(
"ObjectAttributes is %v, want %v"
,
event
.
ObjectAttributes
.
ID
,
1977
)
}
if
event
.
User
.
Name
==
""
{
t
.
Errorf
(
"Username is %s, want %s"
,
event
.
User
.
Name
,
"Administrator"
)
}
if
event
.
Commit
.
Timestamp
==
nil
{
t
.
Errorf
(
"Timestamp isn't nil"
)
}
if
name
:=
event
.
Commit
.
Author
.
Name
;
name
!=
"User"
{
t
.
Errorf
(
"Commit Username is %s, want %s"
,
name
,
"User"
)
}
}
func
TestBuildEventUnmarshal
(
t
*
testing
.
T
)
{
...
...
@@ -595,4 +628,16 @@ func TestMergeEventUnmarshalFromGroup(t *testing.T) {
if
event
.
Assignee
.
Username
!=
"root"
{
t
.
Errorf
(
"Assignee.Username is %v, want %v"
,
event
.
Assignee
,
"root"
)
}
if
event
.
User
.
Name
==
""
{
t
.
Errorf
(
"Username is %s, want %s"
,
event
.
User
.
Name
,
"Administrator"
)
}
if
event
.
ObjectAttributes
.
LastCommit
.
Timestamp
==
nil
{
t
.
Errorf
(
"Timestamp isn't nil"
)
}
if
name
:=
event
.
ObjectAttributes
.
LastCommit
.
Author
.
Name
;
name
!=
"Test User"
{
t
.
Errorf
(
"Commit Username is %s, want %s"
,
name
,
"Test User"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment