Adds a unit test to ensure serializing preserves CR spec in round trip
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
This commit is contained in:
parent
da67eb2b65
commit
07c243df2d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2020 The cert-manager Authors.
|
||||
Copyright 2022 The cert-manager Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2020 The cert-manager Authors.
|
||||
Copyright 2022 The cert-manager Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package certificaterequests
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
@ -56,6 +57,11 @@ func Test_serializeApply(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Regexp(t, expReg, string(reqData))
|
||||
|
||||
// Test round trip preserves the spec and object meta.
|
||||
var rtReq cmapi.CertificateRequest
|
||||
assert.NoError(t, json.Unmarshal(reqData, &rtReq))
|
||||
assert.Equal(t, req.Spec, rtReq.Spec)
|
||||
|
||||
// String match on empty spec.
|
||||
req.Spec = cmapi.CertificateRequestSpec{}
|
||||
reqData, err = serializeApply(&req)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user