Skip to content

Commit

Permalink
Merge pull request #10 from oriser/gomod_and_fix_ci_test
Browse files Browse the repository at this point in the history
Fix CI test + gomod
  • Loading branch information
oriser authored Sep 25, 2024
2 parents 452ca13 + a14145f commit f6bb0e0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
name: Checkout code
- uses: actions/labeler@master
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ require (
require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 10 additions & 4 deletions regroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package regroup
import (
"fmt"
"reflect"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -396,6 +397,11 @@ func TestBooleanExistenceCheck(t *testing.T) {
}
}

func cmpTime(t *testing.T, src time.Time, dst time.Time) {
t.Helper()
assert.Equal(t, strings.Replace(src.String(), " UTC", " +0000", 1), strings.Replace(dst.String(), " UTC", " +0000", 1), "Time not equal")
}

func TestTimeParsing(t *testing.T) {
type TimedStruct struct {
Timestamp time.Time `regroup:"timestamp"`
Expand All @@ -412,10 +418,10 @@ func TestTimeParsing(t *testing.T) {
input: "2012-11-01T22:08:41+00:00/2012-01-02T15:04:05-08:00 PST/2012-01-02T15:04:05+04:00/2024-03-04",
assertions: func(t *testing.T, parsed *TimedStruct, err error) {
assert.NoError(t, err)
assert.Equal(t, time.Date(2012, 11, 1, 22, 8, 41, 0, time.FixedZone("", 0)), parsed.Timestamp)
assert.Equal(t, time.Date(2012, 1, 2, 15, 4, 5, 0, time.FixedZone("PST", -8*60*60)), *parsed.TimestampPtr)
assert.Equal(t, time.Date(2012, 1, 2, 15, 4, 5, 0, time.FixedZone("", 4*60*60)), parsed.TimestampWithPattern)
assert.Equal(t, time.Date(2024, 3, 4, 0, 0, 0, 0, time.UTC), parsed.Date)
cmpTime(t, time.Date(2012, 11, 1, 22, 8, 41, 0, time.FixedZone("", 0)), parsed.Timestamp)
cmpTime(t, time.Date(2012, 1, 2, 15, 4, 5, 0, time.FixedZone("PST", -8*60*60)), (*parsed.TimestampPtr))
cmpTime(t, time.Date(2012, 1, 2, 15, 4, 5, 0, time.FixedZone("", 4*60*60)), parsed.TimestampWithPattern)
cmpTime(t, time.Date(2024, 3, 4, 0, 0, 0, 0, time.UTC), parsed.Date)
},
},
"Missing timezone": {
Expand Down

0 comments on commit f6bb0e0

Please sign in to comment.