mirror of
https://github.com/rclone/rclone.git
synced 2025-12-10 05:13:45 +00:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user