Skip to content

Commit

Permalink
Use SatisfyAll for multiple assertions on the same object
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunyiLyu committed Jan 7, 2021
1 parent 025afe0 commit cb25f3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
23 changes: 12 additions & 11 deletions controllers/rabbitmqcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
))
})

})
})

Expand Down
8 changes: 5 additions & 3 deletions system_tests/system_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit cb25f3b

Please sign in to comment.