diff options
Diffstat (limited to 'time/time_test.go')
-rw-r--r-- | time/time_test.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/time/time_test.go b/time/time_test.go index 5bb6cb2..efb3078 100644 --- a/time/time_test.go +++ b/time/time_test.go @@ -3,7 +3,11 @@ package time -import "testing" +import ( + "fmt" + "testing" + "time" +) func TestDurationToSeconds(t *testing.T) { d, err := Duration("PT3H4M60S") @@ -66,3 +70,24 @@ func TestDurationToSeconds(t *testing.T) { return } } + +func TestIsCurrent(t *testing.T) { + yes, err := IsCurrent("2022-08-07T01:00:00+00:00/PT1H") + if yes || err != nil { + t.Errorf("iscurrent failed: %v: %v", yes, err) + return + } + + h, err := time.ParseDuration("-3600s") + if err != nil { + t.Errorf("-3600s parsing duration: %v", err) + return + } + ts := time.Now().Add(h).UTC().Format(time.RFC3339) + yes, err = IsCurrent(fmt.Sprintf("%s+00:00/PT2H", ts[:len(ts)-1])) + if !yes || err != nil { + t.Errorf("iscurrent failed: %v: %v", yes, err) + return + } + +} |