Commit 7df27d0

mo khan <mo@mokhan.ca>
2024-05-18 19:18:38
feat: parse timestamps
1 parent bf72590
Changed files (2)
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) {
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)
 		})
 	})
 }