From 81654a9195175faa9c4efa8f6a77dee77028d19d Mon Sep 17 00:00:00 2001 From: James Munnelly Date: Fri, 29 May 2020 14:09:25 +0100 Subject: [PATCH] ctl: add integration test case that exercises actual object conversion Signed-off-by: James Munnelly --- test/integration/ctl/ctl_convert_test.go | 24 +++++++++++++++++++ ...t_resource_with_organization_v1alpha2.yaml | 15 ++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/integration/ctl/testdata/convert_resource_with_organization_v1alpha2.yaml diff --git a/test/integration/ctl/ctl_convert_test.go b/test/integration/ctl/ctl_convert_test.go index a91d667d9..bf4682a2d 100644 --- a/test/integration/ctl/ctl_convert_test.go +++ b/test/integration/ctl/ctl_convert_test.go @@ -29,6 +29,7 @@ const ( testdataResource1 = "./testdata/convert_resource1.yaml" testdataResource2 = "./testdata/convert_resource2.yaml" testdataResource3 = "./testdata/convert_resource3.yaml" + testdataResourceWithOrganizationV1alpha2 = "./testdata/convert_resource_with_organization_v1alpha2.yaml" targetv1alpha2 = "cert-manager.io/v1alpha2" targetv1alpha3 = "cert-manager.io/v1alpha3" @@ -82,6 +83,29 @@ func TestCtlConvert(t *testing.T) { targetVersion: targetv1alpha3, expErr: true, }, + "an object in v1alpha2 that uses a field that has been renamed in v1alpha3 should be converted properly": { + input: testdataResourceWithOrganizationV1alpha2, + targetVersion: targetv1alpha3, + expOutput: ` +apiVersion: cert-manager.io/v1alpha3 +kind: Certificate +metadata: + creationTimestamp: null + name: ca-issuer + namespace: sandbox +spec: + commonName: my-csi-app + isCA: true + subject: + organizations: + - hello world + issuerRef: + group: cert-manager.io + kind: Issuer + name: selfsigned-issuer + secretName: ca-key-pair +status: {}`, + }, } for name, test := range tests { diff --git a/test/integration/ctl/testdata/convert_resource_with_organization_v1alpha2.yaml b/test/integration/ctl/testdata/convert_resource_with_organization_v1alpha2.yaml new file mode 100644 index 000000000..cf23a6d1b --- /dev/null +++ b/test/integration/ctl/testdata/convert_resource_with_organization_v1alpha2.yaml @@ -0,0 +1,15 @@ +apiVersion: cert-manager.io/v1alpha2 +kind: Certificate +metadata: + name: ca-issuer + namespace: sandbox +spec: + isCA: true + secretName: ca-key-pair + organization: + - "hello world" + commonName: my-csi-app + issuerRef: + name: selfsigned-issuer + kind: Issuer + group: cert-manager.io