From 47670c7ed85347e409966401219ae0e32f2f194b Mon Sep 17 00:00:00 2001 From: Ramon Quitales Date: Wed, 11 Sep 2024 23:11:07 -0700 Subject: [PATCH] tests: fix mocked CRDs to be valid Our mocked CRDs for testing purposes were very minimal and not completely valid since previous codegen logic only needed a subset of fields. As we have updated our implementation to do codegen on an OpenAPI spec, we need fully formed CRD manifests for this conversion to occur. --- tests/crds/k8sversion/mock_crd.yaml | 4 +++- tests/crds/regression/hyphenated-symbols/hyphen-test.yml | 2 ++ tests/crds/regression/hyphenated-symbols2/hyphen-test2.yml | 2 ++ tests/crds/underscored-types/networkpolicy.yaml | 2 +- tests/crds_test.go | 5 +++-- tests/unneeded_go_files_test.go | 2 ++ 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/crds/k8sversion/mock_crd.yaml b/tests/crds/k8sversion/mock_crd.yaml index 25038d1..ad46df3 100644 --- a/tests/crds/k8sversion/mock_crd.yaml +++ b/tests/crds/k8sversion/mock_crd.yaml @@ -9,9 +9,11 @@ spec: scope: Namespaced versions: - test: + served: true + storage: true name: test schema: openAPIV3Schema: properties: testProperty: - type: string` + type: string diff --git a/tests/crds/regression/hyphenated-symbols/hyphen-test.yml b/tests/crds/regression/hyphenated-symbols/hyphen-test.yml index 381c27b..44f4709 100644 --- a/tests/crds/regression/hyphenated-symbols/hyphen-test.yml +++ b/tests/crds/regression/hyphenated-symbols/hyphen-test.yml @@ -11,6 +11,8 @@ spec: scope: Namespaced versions: - name: HyphenTest + served: true + storage: true schema: openAPIV3Schema: type: object diff --git a/tests/crds/regression/hyphenated-symbols2/hyphen-test2.yml b/tests/crds/regression/hyphenated-symbols2/hyphen-test2.yml index 86c4e05..c11b8d9 100644 --- a/tests/crds/regression/hyphenated-symbols2/hyphen-test2.yml +++ b/tests/crds/regression/hyphenated-symbols2/hyphen-test2.yml @@ -10,6 +10,8 @@ spec: scope: Namespaced versions: - hyphentest2: + storage: true + served: true name: hyphentest2 schema: openAPIV3Schema: diff --git a/tests/crds/underscored-types/networkpolicy.yaml b/tests/crds/underscored-types/networkpolicy.yaml index 14faeee..4f135af 100644 --- a/tests/crds/underscored-types/networkpolicy.yaml +++ b/tests/crds/underscored-types/networkpolicy.yaml @@ -21,12 +21,12 @@ spec: - anp - anps singular: networkpolicy - preserveUnknownFields: true scope: Namespaced versions: - name: v1alpha1 schema: openAPIV3Schema: + type: object properties: spec: type: object diff --git a/tests/crds_test.go b/tests/crds_test.go index b35070d..72078e2 100644 --- a/tests/crds_test.go +++ b/tests/crds_test.go @@ -158,7 +158,7 @@ func TestKubernetesVersionNodeJs(t *testing.T) { version, err := exec.Command("node", "bin/index.js").Output() require.NoError(t, err) - assert.Equal(t, "4.5.5\n", string(version)) + assert.Equal(t, "4.18.0\n", string(version)) }) } @@ -185,9 +185,10 @@ func appendFile(t *testing.T, filename, content string) { } func runRequireNoError(t *testing.T, cmd *exec.Cmd) { + t.Helper() bytes, err := cmd.CombinedOutput() if err != nil { - t.Log(bytes) + t.Log(string(bytes)) } require.NoError(t, err) } diff --git a/tests/unneeded_go_files_test.go b/tests/unneeded_go_files_test.go index 5457c19..08e1b0b 100644 --- a/tests/unneeded_go_files_test.go +++ b/tests/unneeded_go_files_test.go @@ -21,6 +21,8 @@ spec: scope: Namespaced versions: - test: + storage: true + served: true name: test schema: openAPIV3Schema: