mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-06-04 23:12:29 +02:00
Add more tests.
This commit is contained in:
parent
762d1512c4
commit
1687c80122
|
@ -63,3 +63,27 @@ func TestLoopbackNatsClient_Subscribe(t *testing.T) {
|
|||
testNatsClient_Subscribe(t, client)
|
||||
})
|
||||
}
|
||||
|
||||
func TestLoopbackClient_PublishAfterClose(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client := CreateLoopbackNatsClientForTest(t)
|
||||
|
||||
testNatsClient_PublishAfterClose(t, client)
|
||||
})
|
||||
}
|
||||
|
||||
func TestLoopbackClient_SubscribeAfterClose(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client := CreateLoopbackNatsClientForTest(t)
|
||||
|
||||
testNatsClient_SubscribeAfterClose(t, client)
|
||||
})
|
||||
}
|
||||
|
||||
func TestLoopbackClient_BadSubjects(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client := CreateLoopbackNatsClientForTest(t)
|
||||
|
||||
testNatsClient_BadSubjects(t, client)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -109,3 +109,61 @@ func TestNatsClient_Subscribe(t *testing.T) {
|
|||
testNatsClient_Subscribe(t, client)
|
||||
})
|
||||
}
|
||||
|
||||
func testNatsClient_PublishAfterClose(t *testing.T, client NatsClient) {
|
||||
client.Close()
|
||||
|
||||
if err := client.Publish("foo", "bar"); err != nats.ErrConnectionClosed {
|
||||
t.Errorf("Expected %v, got %v", nats.ErrConnectionClosed, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNatsClient_PublishAfterClose(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client, shutdown := CreateLocalNatsClientForTest(t)
|
||||
defer shutdown()
|
||||
|
||||
testNatsClient_PublishAfterClose(t, client)
|
||||
})
|
||||
}
|
||||
|
||||
func testNatsClient_SubscribeAfterClose(t *testing.T, client NatsClient) {
|
||||
client.Close()
|
||||
|
||||
ch := make(chan *nats.Msg)
|
||||
if _, err := client.Subscribe("foo", ch); err != nats.ErrConnectionClosed {
|
||||
t.Errorf("Expected %v, got %v", nats.ErrConnectionClosed, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNatsClient_SubscribeAfterClose(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client, shutdown := CreateLocalNatsClientForTest(t)
|
||||
defer shutdown()
|
||||
|
||||
testNatsClient_SubscribeAfterClose(t, client)
|
||||
})
|
||||
}
|
||||
|
||||
func testNatsClient_BadSubjects(t *testing.T, client NatsClient) {
|
||||
subjects := []string{
|
||||
"foo bar",
|
||||
"foo.",
|
||||
}
|
||||
|
||||
ch := make(chan *nats.Msg)
|
||||
for _, s := range subjects {
|
||||
if _, err := client.Subscribe(s, ch); err != nats.ErrBadSubject {
|
||||
t.Errorf("Expected %v for subject %s, got %v", nats.ErrBadSubject, s, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNatsClient_BadSubjects(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client, shutdown := CreateLocalNatsClientForTest(t)
|
||||
defer shutdown()
|
||||
|
||||
testNatsClient_BadSubjects(t, client)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue