forked from TrueCloudLab/rclone
rc: fix output of Time values in options/get
Before this change these were output as `{}` after this change they are output as time strings `"2022-03-26T17:48:19Z"` in standard javascript format.
This commit is contained in:
parent
0468375054
commit
31caa019fa
2 changed files with 25 additions and 0 deletions
|
@ -153,3 +153,23 @@ func TestParseTimeUnmarshalJSON(t *testing.T) {
|
|||
assert.Equal(t, Time(test.want), parsedTime, test.in)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseTimeMarshalJSON(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
in time.Time
|
||||
want string
|
||||
err bool
|
||||
}{
|
||||
{time.Time{}, `"0001-01-01T00:00:00Z"`, false},
|
||||
{time.Date(2022, 03, 26, 17, 48, 19, 0, time.UTC), `"2022-03-26T17:48:19Z"`, false},
|
||||
} {
|
||||
gotBytes, err := json.Marshal(test.in)
|
||||
got := string(gotBytes)
|
||||
if test.err {
|
||||
require.Error(t, err, test.in)
|
||||
} else {
|
||||
require.NoError(t, err, test.in)
|
||||
}
|
||||
assert.Equal(t, test.want, got, test.in)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue