diff options
author | Matej Vasek <mvasek@redhat.com> | 2021-08-04 21:30:47 +0200 |
---|---|---|
committer | Matej Vasek <mvasek@redhat.com> | 2021-08-04 21:30:47 +0200 |
commit | 8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5 (patch) | |
tree | 564c014eb7960b6535fba7ec8ee8efd6030a90ca /pkg/util/utils_test.go | |
parent | 77f8c6549ab1df393f613cc13e93e8dcec859614 (diff) | |
download | podman-8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5.tar.gz podman-8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5.tar.bz2 podman-8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5.zip |
Fix TS parsing for fractional values
Parse Unix timestamps that contains fractional part.
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'pkg/util/utils_test.go')
-rw-r--r-- | pkg/util/utils_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go index cb737bd76..027acbdab 100644 --- a/pkg/util/utils_test.go +++ b/pkg/util/utils_test.go @@ -2,6 +2,7 @@ package util import ( "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -277,3 +278,17 @@ func TestPeriodAndQuotaToCores(t *testing.T) { assert.Equal(t, PeriodAndQuotaToCores(period, quota), expectedCores) } + +func TestParseInputTime(t *testing.T) { + tm, err := ParseInputTime("1.5") + if err != nil { + t.Errorf("expected error to be nil but was: %v", err) + } + + expected, err := time.ParseInLocation(time.RFC3339Nano, "1970-01-01T00:00:01.500000000Z", time.UTC) + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, expected, tm) +} |