From 7df27d0d0afd5068efedc4cf72c0a7b365af02f8 Mon Sep 17 00:00:00 2001 From: mo khan Date: Sat, 18 May 2024 13:18:38 -0600 Subject: feat: parse timestamps --- pkg/gitlab/issue.go | 3 +++ pkg/gitlab/issue_test.go | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'pkg') 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) }) }) } -- cgit v1.2.3