diff options
| author | mo khan <mo@mokhan.ca> | 2024-05-18 13:18:38 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2024-05-18 13:18:38 -0600 |
| commit | 7df27d0d0afd5068efedc4cf72c0a7b365af02f8 (patch) | |
| tree | 8a336f9503dec63f8c897cab68cb0713517c4474 | |
| parent | bf725905bd53609c6be690bd6fbbb514d3a527ae (diff) | |
feat: parse timestamps
| -rw-r--r-- | pkg/gitlab/issue.go | 3 | ||||
| -rw-r--r-- | pkg/gitlab/issue_test.go | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/pkg/gitlab/issue.go b/pkg/gitlab/issue.go index 2a21e84..7db9a05 100644 --- a/pkg/gitlab/issue.go +++ b/pkg/gitlab/issue.go @@ -2,6 +2,7 @@ package gitlab import ( "io" + "time" "github.com/xlgmokha/x/pkg/serde" ) @@ -19,6 +20,8 @@ type Issue struct { Title string `json:"title"` Description string `json:"description"` State IssueState `json:"state"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` } func FromIssues(r io.Reader) ([]Issue, error) { diff --git a/pkg/gitlab/issue_test.go b/pkg/gitlab/issue_test.go index 0d15061..6ecc526 100644 --- a/pkg/gitlab/issue_test.go +++ b/pkg/gitlab/issue_test.go @@ -5,9 +5,11 @@ import ( "os" "strings" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/xlgmokha/x/pkg/x" ) func TestIssue(t *testing.T) { @@ -43,6 +45,8 @@ func TestIssue(t *testing.T) { 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, 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) }) }) } |
