mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
Add test to ensure backward compatability for timestamps
Change-Id: I63650c77e3d0ece06eb29efa5b8898b77db677fb
This commit is contained in:
parent
65da81f42e
commit
6b8f238205
@ -244,6 +244,29 @@ func TestEncodePtr(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeTimeStampWithoutQuotes(t *testing.T) {
|
||||
testYAML := []byte(`
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
creationTimestamp: 2018-08-30T14:10:58Z
|
||||
name: test
|
||||
spec:
|
||||
containers: null
|
||||
status: {}`)
|
||||
if obj, err := runtime.Decode(testapi.Default.Codec(), testYAML); err != nil {
|
||||
t.Fatalf("unable to decode yaml: %v", err)
|
||||
} else {
|
||||
if obj2, ok := obj.(*api.Pod); !ok {
|
||||
t.Fatalf("Got wrong type")
|
||||
} else {
|
||||
if obj2.ObjectMeta.CreationTimestamp.UnixNano() != parseTimeOrDie("2018-08-30T14:10:58Z").UnixNano() {
|
||||
t.Fatalf("Time stamps do not match")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestBadJSONRejection establishes that a JSON object without a kind or with
|
||||
// an unknown kind will not be decoded without error.
|
||||
func TestBadJSONRejection(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user