From cb25f3bd331e28c1f325a499d6106e47e3fdd5bb Mon Sep 17 00:00:00 2001 From: Chunyi Lyu Date: Thu, 7 Jan 2021 14:54:19 +0000 Subject: [PATCH] Use SatisfyAll for multiple assertions on the same object --- .../rabbitmqcluster_controller_test.go | 23 ++++++++++--------- system_tests/system_tests.go | 8 ++++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/controllers/rabbitmqcluster_controller_test.go b/controllers/rabbitmqcluster_controller_test.go index d7ddef9e2..d94444410 100644 --- a/controllers/rabbitmqcluster_controller_test.go +++ b/controllers/rabbitmqcluster_controller_test.go @@ -144,18 +144,19 @@ var _ = Describe("RabbitmqClusterController", func() { }) By("recording SuccessfulCreate events for all child resources", func() { allEventMsgs := aggregateEventMsgs(ctx, cluster, "SuccessfulCreate") - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.StatefulSet", cluster.ChildResourceName("server"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.Service", cluster.ChildResourceName(""))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.Service", cluster.ChildResourceName("nodes"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.ConfigMap", cluster.ChildResourceName("plugins-conf"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.ConfigMap", cluster.ChildResourceName("server-conf"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.Secret", cluster.ChildResourceName("erlang-cookie"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.Secret", cluster.ChildResourceName("default-user"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.ServiceAccount", cluster.ChildResourceName("server"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.Role", cluster.ChildResourceName("peer-discovery"))) - Expect(allEventMsgs).To(ContainSubstring("created resource %s of Type *v1.RoleBinding", cluster.ChildResourceName("server"))) + Expect(allEventMsgs).To(SatisfyAll( + ContainSubstring("created resource %s of Type *v1.StatefulSet", cluster.ChildResourceName("server")), + ContainSubstring("created resource %s of Type *v1.Service", cluster.ChildResourceName("")), + ContainSubstring("created resource %s of Type *v1.Service", cluster.ChildResourceName("nodes")), + ContainSubstring("created resource %s of Type *v1.ConfigMap", cluster.ChildResourceName("plugins-conf")), + ContainSubstring("created resource %s of Type *v1.ConfigMap", cluster.ChildResourceName("server-conf")), + ContainSubstring("created resource %s of Type *v1.Secret", cluster.ChildResourceName("erlang-cookie")), + ContainSubstring("created resource %s of Type *v1.Secret", cluster.ChildResourceName("default-user")), + ContainSubstring("created resource %s of Type *v1.ServiceAccount", cluster.ChildResourceName("server")), + ContainSubstring("created resource %s of Type *v1.Role", cluster.ChildResourceName("peer-discovery")), + ContainSubstring("created resource %s of Type *v1.RoleBinding", cluster.ChildResourceName("server")), + )) }) - }) }) diff --git a/system_tests/system_tests.go b/system_tests/system_tests.go index 4216e2633..7d145e7da 100644 --- a/system_tests/system_tests.go +++ b/system_tests/system_tests.go @@ -176,9 +176,11 @@ cluster_keepalive_interval = 10000` // verify that rabbitmq.conf contains provided configurations cfgMap := getConfigFileFromPod(namespace, cluster, "/etc/rabbitmq/rabbitmq.conf") - Expect(cfgMap).To(HaveKeyWithValue("vm_memory_high_watermark_paging_ratio", "0.5")) - Expect(cfgMap).To(HaveKeyWithValue("cluster_keepalive_interval", "10000")) - Expect(cfgMap).To(HaveKeyWithValue("cluster_partition_handling", "ignore")) + Expect(cfgMap).To(SatisfyAll( + HaveKeyWithValue("vm_memory_high_watermark_paging_ratio", "0.5"), + HaveKeyWithValue("cluster_keepalive_interval", "10000"), + HaveKeyWithValue("cluster_partition_handling", "ignore"), + )) }) By("updating the advanced.config file when advancedConfig are modified", func() {