mirror of https://github.com/pulumi/pulumi.git
37 lines
1003 B
Go
37 lines
1003 B
Go
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseSince(t *testing.T) {
|
|
a, _ := parseSince("", time.Now())
|
|
assert.Nil(t, a)
|
|
|
|
now := time.Now().UTC()
|
|
b, _ := parseSince("1m30s", now)
|
|
assert.True(t, b.UnixNano() < now.UnixNano())
|
|
fmt.Printf("Res: %v\n", b)
|
|
|
|
c, _ := parseSince("2006-01-02T15:04:05", time.Now().UTC())
|
|
assert.Equal(t, "2006-01-02T15:04:05Z", c.UTC().Format(time.RFC3339))
|
|
|
|
d, _ := parseSince("2006-01-02", time.Now().UTC())
|
|
assert.Equal(t, "2006-01-02T00:00:00Z", d.UTC().Format(time.RFC3339))
|
|
|
|
pst, err := time.LoadLocation("America/Los_Angeles")
|
|
assert.Nil(t, err)
|
|
|
|
e, _ := parseSince("2006-01-02T15:04:05-08:00", time.Now().In(pst))
|
|
assert.Equal(t, "2006-01-02T15:04:05-08:00", e.In(pst).Format(time.RFC3339))
|
|
|
|
f, _ := parseSince("2006-01-02-08:00", time.Now().In(pst))
|
|
assert.Equal(t, "2006-01-02T00:00:00-08:00", f.In(pst).Format(time.RFC3339))
|
|
}
|