diff options
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/gitlab/issue.go | 17 | ||||
| -rw-r--r-- | pkg/gitlab/issue_test.go | 11 |
2 files changed, 22 insertions, 6 deletions
diff --git a/pkg/gitlab/issue.go b/pkg/gitlab/issue.go index 959ade6..2a21e84 100644 --- a/pkg/gitlab/issue.go +++ b/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) { diff --git a/pkg/gitlab/issue_test.go b/pkg/gitlab/issue_test.go index 3c969fa..0d15061 100644 --- a/pkg/gitlab/issue_test.go +++ b/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) }) }) } |
