-
Notifications
You must be signed in to change notification settings - Fork 62
/
binding_types_test.go
84 lines (78 loc) · 2.32 KB
/
binding_types_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
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
78
79
80
81
82
83
84
package v1beta1
import (
"context"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
)
var _ = Describe("Binding spec", func() {
var (
namespace = "default"
ctx = context.Background()
)
It("creates a binding with default settings", func() {
expectedSpec := BindingSpec{
Vhost: "/",
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
},
}
binding := Binding{
ObjectMeta: metav1.ObjectMeta{
Name: "test-binding",
Namespace: namespace,
},
Spec: BindingSpec{
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "some-cluster",
},
},
}
Expect(k8sClient.Create(ctx, &binding)).To(Succeed())
fetchedBinding := &Binding{}
Expect(k8sClient.Get(ctx, types.NamespacedName{
Name: binding.Name,
Namespace: binding.Namespace,
}, fetchedBinding)).To(Succeed())
Expect(fetchedBinding.Spec).To(Equal(expectedSpec))
})
It("creates a binding with configurations", func() {
binding := Binding{
ObjectMeta: metav1.ObjectMeta{
Name: "random-binding",
Namespace: namespace,
},
Spec: BindingSpec{
Vhost: "/avhost",
Source: "anexchange",
Destination: "aqueue",
DestinationType: "queue",
RoutingKey: "akey",
Arguments: &runtime.RawExtension{
Raw: []byte(`{"argument":"argument-value"}`),
},
RabbitmqClusterReference: RabbitmqClusterReference{
Name: "random-cluster",
},
},
}
Expect(k8sClient.Create(ctx, &binding)).To(Succeed())
fetchedBinding := &Binding{}
Expect(k8sClient.Get(ctx, types.NamespacedName{
Name: binding.Name,
Namespace: binding.Namespace,
}, fetchedBinding)).To(Succeed())
Expect(fetchedBinding.Spec.Vhost).To(Equal("/avhost"))
Expect(fetchedBinding.Spec.Source).To(Equal("anexchange"))
Expect(fetchedBinding.Spec.Destination).To(Equal("aqueue"))
Expect(fetchedBinding.Spec.DestinationType).To(Equal("queue"))
Expect(fetchedBinding.Spec.RoutingKey).To(Equal("akey"))
Expect(fetchedBinding.Spec.RabbitmqClusterReference).To(Equal(
RabbitmqClusterReference{
Name: "random-cluster",
}))
Expect(fetchedBinding.Spec.Arguments.Raw).To(Equal([]byte(`{"argument":"argument-value"}`)))
})
})