-
Notifications
You must be signed in to change notification settings - Fork 0
/
broker_client_test.go
43 lines (37 loc) · 964 Bytes
/
broker_client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package carrot
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestShouldConnectToRabbit(t *testing.T) {
Convey("should connect to rabbitmq api", t, func() {
connConfig := &ConnectionConfig{
Host: "localhost",
Username: "guest",
Password: "guest",
}
client, err := NewBrokerClient(connConfig)
So(err, ShouldBeNil)
f, err := client.api.ListVhosts()
So(err, ShouldBeNil)
So(len(f), ShouldBeGreaterThan, 0)
})
Convey("should not connect to rabbitmq api", t, func() {
connConfig := &ConnectionConfig{
Host: "localhos",
Username: "guest",
Password: "guest",
}
_, err := NewBrokerClient(connConfig)
So(err, ShouldNotBeNil)
})
Convey("should not create api client when url cannot be parsed", t, func() {
connConfig := &ConnectionConfig{
Host: "localh*& os",
Username: "guest",
Password: "guest",
}
_, err := NewBrokerClient(connConfig)
So(err, ShouldNotBeNil)
})
}