forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_test.go
More file actions
77 lines (65 loc) · 2.06 KB
/
add_test.go
File metadata and controls
77 lines (65 loc) · 2.06 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package cluster_test
import (
"context"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/client-go/rest"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/controller/controllertest"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
. "github.com/gardener/gardener/pkg/operator/controller/virtual/cluster"
)
var _ = Describe("Add", func() {
var (
ctx context.Context
reconciler *Reconciler
restConfig *rest.Config
)
BeforeEach(func() {
ctx = context.Background()
reconciler = &Reconciler{}
restConfig = &rest.Config{Host: "http://api.foo.bar"}
})
Describe("EventHandler", func() {
var (
eventHandler handler.TypedEventHandler[*rest.Config, Request]
queue workqueue.TypedRateLimitingInterface[Request]
)
BeforeEach(func() {
eventHandler = reconciler.EventHandler()
queue = &controllertest.TypedQueue[Request]{
TypedInterface: workqueue.NewTyped[Request](),
}
})
Describe("#Generic", func() {
It("should add the REST config", func() {
eventHandler.Generic(ctx, event.TypedGenericEvent[*rest.Config]{Object: restConfig}, queue)
item, shutdown := queue.Get()
ExpectWithOffset(1, shutdown).To(BeFalse())
ExpectWithOffset(1, item.RESTConfig).To(Equal(restConfig))
})
})
Describe("#Create", func() {
It("should do nothing", func() {
eventHandler.Create(ctx, event.TypedCreateEvent[*rest.Config]{Object: restConfig}, queue)
Expect(queue.Len()).To(Equal(0))
})
})
Describe("#Update", func() {
It("should do nothing", func() {
eventHandler.Update(ctx, event.TypedUpdateEvent[*rest.Config]{ObjectNew: restConfig}, queue)
Expect(queue.Len()).To(Equal(0))
})
})
Describe("#Delete", func() {
It("should do nothing", func() {
eventHandler.Delete(ctx, event.TypedDeleteEvent[*rest.Config]{Object: restConfig}, queue)
Expect(queue.Len()).To(Equal(0))
})
})
})
})