mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Fuzz util.Time with no nsec because JSON
This commit is contained in:
parent
b3304c49ad
commit
0b38282b9b
@ -19,6 +19,8 @@ package util
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/gofuzz"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Time is a wrapper around time.Time which supports correct
|
// Time is a wrapper around time.Time which supports correct
|
||||||
@ -89,3 +91,13 @@ func (t Time) MarshalJSON() ([]byte, error) {
|
|||||||
|
|
||||||
return json.Marshal(t.Format(time.RFC3339))
|
return json.Marshal(t.Format(time.RFC3339))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fuzz satisfies fuzz.Interface.
|
||||||
|
func (t *Time) Fuzz(c fuzz.Continue) {
|
||||||
|
// Allow for about 1000 years of randomness. Leave off nanoseconds
|
||||||
|
// because JSON doesn't represent them so they can't round-trip
|
||||||
|
// properly.
|
||||||
|
t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ fuzz.Interface = &Time{}
|
||||||
|
Loading…
Reference in New Issue
Block a user