summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/helm/helm_test.go
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-10-05 14:36:01 +0200
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-10-05 14:55:01 +0200
commit258e59bf8563021f4eded42b33c6cc61a6ffebd8 (patch)
treef4d536a335401fd357628e5b2ec630ea294686a3 /src/k8splugin/internal/helm/helm_test.go
parent54b79141744e713848ae46f3170c637bc7d08ef8 (diff)
Fixed issue with order of deleted resources0.9.1
For delete operation order of resources is reverse to the order used for creation Issue-ID: MULTICLOUD-1398 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: I3f34c6000222e82c34f59042e99d2c37a343dfa5
Diffstat (limited to 'src/k8splugin/internal/helm/helm_test.go')
-rw-r--r--src/k8splugin/internal/helm/helm_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/k8splugin/internal/helm/helm_test.go b/src/k8splugin/internal/helm/helm_test.go
index b805b59b..951ff92b 100644
--- a/src/k8splugin/internal/helm/helm_test.go
+++ b/src/k8splugin/internal/helm/helm_test.go
@@ -26,6 +26,7 @@ import (
"testing"
"gopkg.in/yaml.v2"
+ "k8s.io/apimachinery/pkg/runtime/schema"
)
func TestProcessValues(t *testing.T) {
@@ -265,3 +266,45 @@ func TestGenerateKubernetesArtifacts(t *testing.T) {
})
}
}
+
+func TestReverseResources(t *testing.T) {
+
+ t.Run("Successfully reverse resources", func(t *testing.T) {
+ data := []KubernetesResource{
+ {
+ GVK: schema.GroupVersionKind{
+ Group: "apps",
+ Version: "v1",
+ Kind: "Deployment"},
+ Name: "deployment-1",
+ },
+ {
+ GVK: schema.GroupVersionKind{
+ Group: "apps",
+ Version: "v1",
+ Kind: "Deployment"},
+ Name: "deployment-2",
+ },
+ {
+ GVK: schema.GroupVersionKind{
+ Group: "",
+ Version: "v1",
+ Kind: "Service"},
+ Name: "service-1",
+ },
+ {
+ GVK: schema.GroupVersionKind{
+ Group: "",
+ Version: "v1",
+ Kind: "Service"},
+ Name: "service-2",
+ },
+ }
+
+ reversed := GetReverseK8sResources(data)
+
+ if reversed[0] != data[len(data)-1] {
+ t.Fatalf("Unexpected k8s resource at position 0 %s", reversed[0])
+ }
+ })
+}