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
mistress
bad 2 years ago
parent a94881f1d4
commit 0fcb27311e

@ -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)
}

Loading…
Cancel
Save