Skip to content

Commit

Permalink
Add unit tests to cover Get* methods in the broker Syncer
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
  • Loading branch information
tpantelis authored and skitt committed Aug 16, 2023
1 parent fd7a320 commit 1c9e6be
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions pkg/syncer/broker/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
utilrand "k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
)
Expand Down Expand Up @@ -490,10 +491,44 @@ var _ = Describe("Broker Syncer", func() {
})
})

When("GetBrokerFederatorFor is called", func() {
It("should return the Federator", func() {
Expect(syncer.GetBrokerFederator()).ToNot(BeNil())
})
Specify("GetBrokerFederator should return the correct instance", func() {
f := syncer.GetBrokerFederator()
Expect(f).ToNot(BeNil())

name := string(uuid.NewUUID())
Expect(f.Distribute(&corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
})).To(Succeed())

test.AwaitResource(brokerClient, name)
})

Specify("GetBrokerClient should return the correct instance", func() {
Expect(syncer.GetBrokerClient()).To(Equal(brokerDynClient))
})

Specify("GetBrokerNamespace should return the correct instance", func() {
Expect(syncer.GetBrokerNamespace()).To(Equal(test.RemoteNamespace))
})

Specify("GetLocalFederator should return the correct instance", func() {
f := syncer.GetLocalFederator()
Expect(f).ToNot(BeNil())

name := string(uuid.NewUUID())
Expect(f.Distribute(&corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
})).To(Succeed())

test.AwaitResource(localClient, name)
})

Specify("GetLocalClient should return the correct instance", func() {
Expect(syncer.GetLocalClient()).To(Equal(localDynClient))
})

When("GetLocalResource is called", func() {
Expand Down

0 comments on commit 1c9e6be

Please sign in to comment.