From 0636368c8ca3377aed7d71bd83ca8d3913c6a00f Mon Sep 17 00:00:00 2001 From: jregan Date: Fri, 24 Apr 2020 15:10:59 -0700 Subject: [PATCH] More GVK tests before GV treatment changes. --- api/filters/fsslice/gvk_test.go | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/api/filters/fsslice/gvk_test.go b/api/filters/fsslice/gvk_test.go index 151d7dbed..66f23b14a 100644 --- a/api/filters/fsslice/gvk_test.go +++ b/api/filters/fsslice/gvk_test.go @@ -11,6 +11,67 @@ import ( "sigs.k8s.io/kustomize/kyaml/yaml" ) +func TestParseGV(t *testing.T) { + testCases := map[string]struct { + input string + expectedGroup string + expectedVersion string + }{ + "empty": { + input: "", + expectedGroup: "", + expectedVersion: "", + }, + "certSigning": { + input: "certificates.k8s.io/v1beta1", + expectedGroup: "certificates.k8s.io", + expectedVersion: "v1beta1", + }, + "extensions": { + input: "extensions/v1beta1", + expectedGroup: "extensions", + expectedVersion: "v1beta1", + }, + "normal": { + input: "apps/v1", + expectedGroup: "apps", + expectedVersion: "v1", + }, + "justApps": { + input: "apps", + expectedGroup: "apps", + expectedVersion: "", + }, + "coreV1": { + input: "v1", + expectedGroup: "v1", + expectedVersion: "", + }, + "coreV2": { + input: "v2", + expectedGroup: "v2", + expectedVersion: "", + }, + "coreV2Beta1": { + input: "v2beta1", + expectedGroup: "v2beta1", + expectedVersion: "", + }, + } + + for tn, tc := range testCases { + t.Run(tn, func(t *testing.T) { + group, version := parseGV(tc.input) + if !assert.Equal(t, tc.expectedGroup, group) { + t.FailNow() + } + if !assert.Equal(t, tc.expectedVersion, version) { + t.FailNow() + } + }) + } +} + func TestGetGVK(t *testing.T) { testCases := map[string]struct { input string