forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_test.go
More file actions
58 lines (49 loc) · 1.88 KB
/
add_test.go
File metadata and controls
58 lines (49 loc) · 1.88 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package care_test
import (
"context"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
resourcesv1alpha1 "github.com/gardener/gardener/pkg/apis/resources/v1alpha1"
. "github.com/gardener/gardener/pkg/operator/controller/extension/care"
)
var _ = Describe("Add", func() {
Describe("#MapManagedResourceToExtension", func() {
var (
ctx context.Context
careReconciler *Reconciler
)
BeforeEach(func() {
ctx = context.Background()
careReconciler = &Reconciler{
GardenNamespace: "garden",
}
})
DescribeTable("map a managed resource to an extension",
func(namespace, name, expectedExtension string) {
managedResource := &resourcesv1alpha1.ManagedResource{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: name,
},
}
result := careReconciler.MapManagedResourceToExtension(ctx, managedResource)
if expectedExtension != "" {
Expect(result).To(ConsistOf(reconcile.Request{NamespacedName: types.NamespacedName{Name: expectedExtension}}))
} else {
Expect(result).To(BeEmpty())
}
},
Entry("non-extension managed resource in garden namespace", "garden", "foobar", ""),
Entry("managed resource for extension in non-garden namespace", "goo", "extension-foobar-garden", ""),
Entry("managed resource for extension", "garden", "extension-foobar-garden", "foobar"),
Entry("managed resource for runtime resources of extension admission", "garden", "extension-admission-runtime-foobar", "foobar"),
Entry("managed resource for virtual resources of extension admission", "garden", "extension-admission-virtual-foobar", "foobar"),
)
})
})