Add test to ensure backward compatability for timestamps

Change-Id: I63650c77e3d0ece06eb29efa5b8898b77db677fb
This commit is contained in:
Davanum Srinivas 2018-10-11 10:13:04 -04:00
parent 65da81f42e
commit 6b8f238205
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59

View File

@ -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) {