Skip to content

Commit 4017d5f

Browse files
committed
Add more store.go tests
1 parent 34e6325 commit 4017d5f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

internal/controller/provisioner/store_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,22 @@ func TestRegisterResourceInGatewayConfig(t *testing.T) {
327327
// Docker Secret again, already exists
328328
resources = registerAndGetResources(dockerSecret)
329329
g.Expect(resources.DockerSecrets).To(ContainElement(dockerSecretMeta))
330+
331+
// clear out resources before next test
332+
store.deleteResourcesForGateway(nsName)
333+
334+
// Dataplane Key Secret
335+
dataplaneKeySecretMeta := metav1.ObjectMeta{
336+
Name: controller.CreateNginxResourceName(defaultMeta.Name, store.dataplaneKeySecretName),
337+
Namespace: defaultMeta.Namespace,
338+
}
339+
dataplaneKeySecret := &corev1.Secret{ObjectMeta: dataplaneKeySecretMeta}
340+
resources = registerAndGetResources(dataplaneKeySecret)
341+
g.Expect(resources.DataplaneKeySecret).To(Equal(dataplaneKeySecretMeta))
342+
343+
// Dataplane Key Secret again, already exists
344+
resources = registerAndGetResources(dataplaneKeySecret)
345+
g.Expect(resources.DataplaneKeySecret).To(Equal(dataplaneKeySecretMeta))
330346
}
331347

332348
func TestGatewayChanged(t *testing.T) {
@@ -500,6 +516,10 @@ func TestGatewayExistsForResource(t *testing.T) {
500516
Namespace: "default",
501517
},
502518
},
519+
DataplaneKeySecret: metav1.ObjectMeta{
520+
Name: "test-dataplane-key-secret",
521+
Namespace: "default",
522+
},
503523
}
504524

505525
tests := []struct {
@@ -637,6 +657,16 @@ func TestGatewayExistsForResource(t *testing.T) {
637657
},
638658
expected: gateway,
639659
},
660+
{
661+
name: "Dataplane Key Secret exists",
662+
object: &corev1.Secret{
663+
ObjectMeta: metav1.ObjectMeta{
664+
Name: "test-dataplane-key-secret",
665+
Namespace: "default",
666+
},
667+
},
668+
expected: gateway,
669+
},
640670
{
641671
name: "Resource does not exist",
642672
object: &corev1.Service{
@@ -733,6 +763,11 @@ func TestGetResourceVersionForObject(t *testing.T) {
733763
ResourceVersion: "13",
734764
},
735765
},
766+
DataplaneKeySecret: metav1.ObjectMeta{
767+
Name: "test-dataplane-key-secret",
768+
Namespace: "default",
769+
ResourceVersion: "14",
770+
},
736771
}
737772

738773
tests := []struct {
@@ -870,6 +905,16 @@ func TestGetResourceVersionForObject(t *testing.T) {
870905
},
871906
expectedResult: "13",
872907
},
908+
{
909+
name: "Dataplane Key Secret resource version",
910+
object: &corev1.Secret{
911+
ObjectMeta: metav1.ObjectMeta{
912+
Name: "test-dataplane-key-secret",
913+
Namespace: "default",
914+
},
915+
},
916+
expectedResult: "14",
917+
},
873918
{
874919
name: "Non-existent resource",
875920
object: &corev1.Service{

0 commit comments

Comments
 (0)