forked from drnic/consul-discovery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatalog_test.go
38 lines (33 loc) · 1016 Bytes
/
catalog_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
package consuldiscovery
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func getClient(t *testing.T) *Client {
client, err := NewClient(DefaultConfig())
if err != nil {
t.Fatalf("err: %v", err)
}
return client
}
func TestCatalog(t *testing.T) {
Convey("CatalogServices", t, func() {
client := getClient(t)
services, err := client.CatalogServices()
So(err, ShouldEqual, nil)
So(len(services), ShouldEqual, 2)
So(services[0].Name, ShouldEqual, "consul")
So(services[1].Name, ShouldEqual, "simple_service")
})
Convey("CatalogServiceByName", t, func() {
client := getClient(t)
nodes, err := client.CatalogServiceByName("simple_service")
So(err, ShouldEqual, nil)
So(len(nodes), ShouldEqual, 1)
So(nodes[0].ServiceID, ShouldEqual, "simple_service")
So(nodes[0].ServiceName, ShouldEqual, "simple_service")
So(nodes[0].ServicePort, ShouldEqual, 6666)
// TODO: So(nodes[0].ServiceTags, ShouldEqual, []string{"tag1", "tag2"})
// TODO: and other fields...
})
}