Commit d2a9990
Changed files (2)
pkg
gitlab
pkg/gitlab/issue.go
@@ -10,9 +10,24 @@ import (
type IssueState string
const (
- StateClosed IssueState = "closed"
+ IssueStateClosed IssueState = "closed"
)
+type UserState string
+
+const (
+ UserStateActive UserState = "active"
+)
+
+type User struct {
+ ID int `json:"id"`
+ Username string `json:"username"`
+ State UserState `json:"state"`
+ Locked bool `json:"locked"`
+ AvatarUrl string `json:"avatar_url"`
+ WebUrl string `json:"web_url"`
+}
+
type Issue struct {
ID int `json:"id"`
IID int `json:"iid"`
@@ -23,6 +38,7 @@ type Issue struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt time.Time `json:"closed_at"`
+ ClosedBy User `json:"closed_by"`
}
func FromIssues(r io.Reader) ([]Issue, error) {
pkg/gitlab/issue_test.go
@@ -44,10 +44,20 @@ func TestIssue(t *testing.T) {
assert.Equal(t, 40549124, result.ProjectID)
assert.Contains(t, result.Title, "`gitlab-org/gitlab` broken `master` with rspec unit")
assert.Contains(t, result.Description, "## How to close this incident\n\n- Follow the steps in the")
- assert.Equal(t, StateClosed, result.State)
+ assert.Equal(t, IssueStateClosed, result.State)
assert.Equal(t, x.Must(time.Parse(time.RFC3339Nano, "2024-05-18T17:39:14.548Z")), result.CreatedAt)
assert.Equal(t, x.Must(time.Parse(time.RFC3339Nano, "2024-05-18T18:14:37.830Z")), result.UpdatedAt)
assert.Equal(t, x.Must(time.Parse(time.RFC3339Nano, "2024-05-18T17:39:16.837Z")), result.ClosedAt)
+
+ t.Run("closed_by", func(t *testing.T) {
+ user := result.ClosedBy
+ assert.Equal(t, 1786152, user.ID)
+ assert.Equal(t, "gitlab-bot", user.Username)
+ assert.Equal(t, UserStateActive, user.State)
+ assert.Equal(t, false, user.Locked)
+ assert.Equal(t, "https://gitlab.com/uploads/-/system/user/avatar/1786152/avatar.png", user.AvatarUrl)
+ assert.Equal(t, "https://gitlab.com/gitlab-bot", user.WebUrl)
+ })
})
})
}