Add integration test for glob support

This commit is contained in:
Jingfang Liu
2018-06-27 11:01:49 -07:00
parent 6392e6629f
commit 2a3f09a2f0
8 changed files with 40 additions and 26 deletions

View File

@@ -6,5 +6,4 @@ commonLabels:
commonAnnotations: commonAnnotations:
note: This is a test annotation note: This is a test annotation
resources: resources:
- deployment.yaml - resources/*.yaml
- service.yaml

View File

@@ -2,8 +2,7 @@ namePrefix: staging-
commonLabels: commonLabels:
env: staging env: staging
patches: patches:
- deployment-patch1.yaml - patches/deployment-patch*.yaml
- deployment-patch2.yaml
bases: bases:
- ../package/ - ../package/
configMapGenerator: configMapGenerator:

View File

@@ -18,6 +18,7 @@ package crds
import ( import (
"reflect" "reflect"
"sort"
"testing" "testing"
"github.com/kubernetes-sigs/kustomize/pkg/internal/loadertest" "github.com/kubernetes-sigs/kustomize/pkg/internal/loadertest"
@@ -150,9 +151,7 @@ func makeLoader(t *testing.T) loader.Loader {
} }
func TestRegisterCRD(t *testing.T) { func TestRegisterCRD(t *testing.T) {
expected := []pathConfigs{ refpathconfigs := []transformers.ReferencePathConfig{
{
namereferencePathConfigs: []transformers.ReferencePathConfig{
transformers.NewReferencePathConfig( transformers.NewReferencePathConfig(
schema.GroupVersionKind{Kind: "Bee", Version: "v1beta1"}, schema.GroupVersionKind{Kind: "Bee", Version: "v1beta1"},
[]transformers.PathConfig{ []transformers.PathConfig{
@@ -173,7 +172,15 @@ func TestRegisterCRD(t *testing.T) {
}, },
}, },
), ),
}, }
sort.Slice(refpathconfigs, func(i, j int) bool {
return refpathconfigs[i].GVK() < refpathconfigs[j].GVK()
})
expected := []pathConfigs{
{
namereferencePathConfigs: refpathconfigs,
}, },
} }
@@ -181,6 +188,10 @@ func TestRegisterCRD(t *testing.T) {
pathconfig, _ := registerCRD(loader, "/testpath/crd.json") pathconfig, _ := registerCRD(loader, "/testpath/crd.json")
sort.Slice(pathconfig[0].namereferencePathConfigs, func(i, j int) bool {
return pathconfig[0].namereferencePathConfigs[i].GVK() < pathconfig[0].namereferencePathConfigs[j].GVK()
})
if !reflect.DeepEqual(pathconfig, expected) { if !reflect.DeepEqual(pathconfig, expected) {
t.Fatalf("expected\n %v\n but got\n %v\n", expected, pathconfig) t.Fatalf("expected\n %v\n but got\n %v\n", expected, pathconfig)
} }

View File

@@ -61,3 +61,8 @@ func NewReferencePathConfig(gvk schema.GroupVersionKind, pathconfigs []PathConfi
pathConfigs: pathconfigs, pathConfigs: pathconfigs,
} }
} }
// GVK returns the Group version kind of a Reference PathConfig
func (r ReferencePathConfig) GVK() string {
return r.referencedGVK.String()
}