-
Notifications
You must be signed in to change notification settings - Fork 53
/
structures_kustomization_test.go
37 lines (27 loc) · 1.15 KB
/
structures_kustomization_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package kustomize
import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/kustomize/api/krusty"
"sigs.k8s.io/kustomize/kyaml/filesys"
)
func TestConvertKustomizationIDs(t *testing.T) {
fSys := filesys.MakeFsOnDisk()
opts := krusty.MakeDefaultOptions()
k := krusty.MakeKustomizer(opts)
rm, err := k.Run(fSys, "test_kustomizations/basic/initial")
assert.Equal(t, err, nil, nil)
ids, idsPrio, err := flattenKustomizationIDs(rm)
assert.Equal(t, err, nil, nil)
expMerged := append(idsPrio[0], idsPrio[1]...)
expMerged = append(expMerged, idsPrio[2]...)
assert.ElementsMatch(t, expMerged, ids, nil)
expIds := []string{"_/Namespace/_/test-basic", "apps/Deployment/test-basic/test", "networking.k8s.io/Ingress/test-basic/test", "_/Service/test-basic/test"}
assert.ElementsMatch(t, expIds, ids, nil)
expP1 := []string{"_/Namespace/_/test-basic"}
assert.ElementsMatch(t, expP1, idsPrio[0], nil)
expP2 := []string{"apps/Deployment/test-basic/test", "networking.k8s.io/Ingress/test-basic/test", "_/Service/test-basic/test"}
assert.ElementsMatch(t, expP2, idsPrio[1], nil)
expP3 := []string{}
assert.ElementsMatch(t, expP3, idsPrio[2], nil)
}