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
This commit is contained in:
bad 2021-10-17 23:02:52 +02:00
parent a94881f1d4
commit 0fcb27311e

View file

@ -25,33 +25,36 @@ func assertMatches(topic packets.Topic, topicName string, shouldMatch bool, t *t
} }
func TestSubscribe(t *testing.T) { func TestSubscribe(t *testing.T) {
t.Parallel()
topic, _ := packets.ParseTopic("a/b/c") topic, _ := packets.ParseTopic("a/b/c")
assertMatches(topic, "a/b/c", true, t) go assertMatches(topic, "a/b/c", true, t)
assertMatches(topic, "a/c/c", false, t) go assertMatches(topic, "a/c/c", false, t)
assertMatches(topic, "b/b/c", false, t) go assertMatches(topic, "b/b/c", false, t)
assertMatches(topic, "aaa/c/a", false, t) go assertMatches(topic, "aaa/c/a", false, t)
} }
func TestSingleLevelWildcard(t *testing.T) { func TestSingleLevelWildcard(t *testing.T) {
t.Parallel()
topic, _ := packets.ParseTopic("a/+/c") topic, _ := packets.ParseTopic("a/+/c")
assertMatches(topic, "a/b/c", true, t) go assertMatches(topic, "a/b/c", true, t)
assertMatches(topic, "a/c/c", true, t) go assertMatches(topic, "a/c/c", true, t)
assertMatches(topic, "a/b/d", false, t) go assertMatches(topic, "a/b/d", false, t)
assertMatches(topic, "aaa/c/a", false, t) go assertMatches(topic, "aaa/c/a", false, t)
topic, _ = packets.ParseTopic("+/+/+") topic, _ = packets.ParseTopic("+/+/+")
assertMatches(topic, "a/b/c", true, t) go assertMatches(topic, "a/b/c", true, t)
assertMatches(topic, "a/c/c", true, t) go assertMatches(topic, "a/c/c", true, t)
assertMatches(topic, "a/b/d/e", false, t) go assertMatches(topic, "a/b/d/e", false, t)
assertMatches(topic, "c/a", true, t) go assertMatches(topic, "c/a", true, t)
} }
func TestMultiLevelWildcard(t *testing.T) { func TestMultiLevelWildcard(t *testing.T) {
t.Parallel()
topic, _ := packets.ParseTopic("a/b/c/#") topic, _ := packets.ParseTopic("a/b/c/#")
assertMatches(topic, "a/b/c", true, t) go assertMatches(topic, "a/b/c", true, t)
assertMatches(topic, "a/b/c/a", true, t) go assertMatches(topic, "a/b/c/a", true, t)
assertMatches(topic, "a/b/c/d", true, t) go assertMatches(topic, "a/b/c/d", true, t)
assertMatches(topic, "a/b/c/f", 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)
} }