Commit f619fdc
Changed files (2)
pkg
gitlab
pkg/gitlab/issue.go
@@ -6,12 +6,19 @@ import (
"github.com/xlgmokha/x/pkg/serde"
)
+type IssueState string
+
+const (
+ StateClosed IssueState = "closed"
+)
+
type Issue struct {
- ID int `json:"id"`
- IID int `json:"iid"`
- ProjectID int `json:"project_id"`
- Title string `json:"title"`
- Description string `json:"description"`
+ ID int `json:"id"`
+ IID int `json:"iid"`
+ ProjectID int `json:"project_id"`
+ Title string `json:"title"`
+ Description string `json:"description"`
+ State IssueState `json:"state"`
}
func FromIssues(r io.Reader) ([]Issue, error) {
pkg/gitlab/issue_test.go
@@ -33,7 +33,16 @@ func TestIssue(t *testing.T) {
results, err := FromIssues(reader)
require.NoError(t, err)
- assert.Equal(t, 20, len(results))
+ assert.Len(t, results, 20)
+
+ result := results[0]
+
+ assert.Equal(t, 146760799, result.ID)
+ assert.Equal(t, 6375, result.IID)
+ 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)
})
})
}