From 0fcb27311ea560cb991319a086bd5686dffe2e88 Mon Sep 17 00:00:00 2001 From: bad Date: Sun, 17 Oct 2021 23:02:52 +0200 Subject: [PATCH] Make subscription tests run in parrarel This should be faster(not like that matters) and sure that the subscription struct can be shared between threads --- subscription/subscription_test.go | 37 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/subscription/subscription_test.go b/subscription/subscription_test.go index 9849b82..e4b4159 100644 --- a/subscription/subscription_test.go +++ b/subscription/subscription_test.go @@ -25,33 +25,36 @@ func assertMatches(topic packets.Topic, topicName string, shouldMatch bool, t *t } func TestSubscribe(t *testing.T) { + t.Parallel() topic, _ := packets.ParseTopic("a/b/c") - assertMatches(topic, "a/b/c", true, t) - assertMatches(topic, "a/c/c", false, t) - assertMatches(topic, "b/b/c", false, t) - assertMatches(topic, "aaa/c/a", false, t) + go assertMatches(topic, "a/b/c", true, t) + go assertMatches(topic, "a/c/c", false, t) + go assertMatches(topic, "b/b/c", false, t) + go assertMatches(topic, "aaa/c/a", false, t) } func TestSingleLevelWildcard(t *testing.T) { + t.Parallel() topic, _ := packets.ParseTopic("a/+/c") - assertMatches(topic, "a/b/c", true, t) - assertMatches(topic, "a/c/c", true, t) - assertMatches(topic, "a/b/d", false, t) - assertMatches(topic, "aaa/c/a", false, t) + go assertMatches(topic, "a/b/c", true, t) + go assertMatches(topic, "a/c/c", true, t) + go assertMatches(topic, "a/b/d", false, t) + go assertMatches(topic, "aaa/c/a", false, t) topic, _ = packets.ParseTopic("+/+/+") - assertMatches(topic, "a/b/c", true, t) - assertMatches(topic, "a/c/c", true, t) - assertMatches(topic, "a/b/d/e", false, t) - assertMatches(topic, "c/a", true, t) + go assertMatches(topic, "a/b/c", true, t) + go assertMatches(topic, "a/c/c", true, t) + go assertMatches(topic, "a/b/d/e", false, t) + go assertMatches(topic, "c/a", true, t) } func TestMultiLevelWildcard(t *testing.T) { + t.Parallel() topic, _ := packets.ParseTopic("a/b/c/#") - assertMatches(topic, "a/b/c", true, t) - assertMatches(topic, "a/b/c/a", true, t) - assertMatches(topic, "a/b/c/d", true, t) - assertMatches(topic, "a/b/c/f", true, t) + go assertMatches(topic, "a/b/c", true, t) + go assertMatches(topic, "a/b/c/a", true, t) + go assertMatches(topic, "a/b/c/d", true, t) + go assertMatches(topic, "a/b/c/f", true, t) - assertMatches(topic, "a/b/d/a", false, t) + go assertMatches(topic, "a/b/d/a", false, t) }