2020-08-25 13:44:41 +03:00
|
|
|
// +build ignore
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
package registry
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2020-01-16 12:48:36 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
2020-07-27 13:22:00 +01:00
|
|
|
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/router"
|
2020-01-16 12:48:36 +00:00
|
|
|
)
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2020-08-25 13:44:41 +03:00
|
|
|
func testSetup(t *testing.T) (*table, router.Route) {
|
|
|
|
r, err := NewRouter()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
routr := r.(*rtr)
|
|
|
|
|
2020-08-07 20:53:38 +01:00
|
|
|
table := newTable(routr.lookup)
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
route := router.Route{
|
2019-07-09 15:45:42 +01:00
|
|
|
Service: "dest.svc",
|
2019-11-05 17:44:24 +00:00
|
|
|
Address: "dest.addr",
|
2019-07-09 15:45:42 +01:00
|
|
|
Gateway: "dest.gw",
|
|
|
|
Network: "dest.network",
|
2019-08-27 23:08:35 +01:00
|
|
|
Router: "src.router",
|
2019-07-09 15:45:42 +01:00
|
|
|
Link: "det.link",
|
|
|
|
Metric: 10,
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
2019-07-01 23:15:45 +01:00
|
|
|
|
|
|
|
return table, route
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 17:46:22 +01:00
|
|
|
func TestCreate(t *testing.T) {
|
2020-08-25 13:44:41 +03:00
|
|
|
table, route := testSetup(t)
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-10 17:46:22 +01:00
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// adds new route for the original destination
|
|
|
|
route.Gateway = "dest.gw2"
|
|
|
|
|
2019-07-10 17:46:22 +01:00
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
2019-07-08 16:16:50 +01:00
|
|
|
// adding the same route under Insert policy must error
|
2020-07-27 13:22:00 +01:00
|
|
|
if err := table.Create(route); err != router.ErrDuplicateRoute {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route. Expected error: %s, found: %s", router.ErrDuplicateRoute, err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDelete(t *testing.T) {
|
2020-08-25 13:44:41 +03:00
|
|
|
table, route := testSetup(t)
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-10 17:46:22 +01:00
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
2020-08-25 14:33:36 +03:00
|
|
|
// should fail to delete non-existent route
|
2019-07-09 15:45:42 +01:00
|
|
|
prevSvc := route.Service
|
|
|
|
route.Service = "randDest"
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
if err := table.Delete(route); err != router.ErrRouteNotFound {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error deleting route. Expected: %s, found: %s", router.ErrRouteNotFound, err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
2019-07-01 23:36:22 +01:00
|
|
|
// we should be able to delete the existing route
|
2019-07-09 15:45:42 +01:00
|
|
|
route.Service = prevSvc
|
2019-07-01 22:57:27 +01:00
|
|
|
|
|
|
|
if err := table.Delete(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error deleting route: %s", err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpdate(t *testing.T) {
|
2020-08-25 13:44:41 +03:00
|
|
|
table, route := testSetup(t)
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-10 17:46:22 +01:00
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
2019-07-01 23:36:22 +01:00
|
|
|
// change the metric of the original route
|
2019-07-01 22:57:27 +01:00
|
|
|
route.Metric = 200
|
|
|
|
|
|
|
|
if err := table.Update(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error updating route: %s", err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 21:28:32 +01:00
|
|
|
// this should add a new route
|
2019-07-09 15:45:42 +01:00
|
|
|
route.Service = "rand.dest"
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-10 21:28:32 +01:00
|
|
|
if err := table.Update(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error updating route: %s", err)
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-08 21:03:54 +01:00
|
|
|
func TestList(t *testing.T) {
|
2020-08-25 13:44:41 +03:00
|
|
|
table, route := testSetup(t)
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-09 15:45:42 +01:00
|
|
|
svc := []string{"one.svc", "two.svc", "three.svc"}
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-09 15:45:42 +01:00
|
|
|
for i := 0; i < len(svc); i++ {
|
|
|
|
route.Service = svc[i]
|
2019-07-10 17:46:22 +01:00
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
|
2019-07-08 21:03:54 +01:00
|
|
|
routes, err := table.List()
|
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error listing routes: %s", err)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
2019-07-01 22:57:27 +01:00
|
|
|
|
2019-07-09 15:45:42 +01:00
|
|
|
if len(routes) != len(svc) {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes listed. Expected: %d, found: %d", len(svc), len(routes))
|
2019-07-01 22:57:27 +01:00
|
|
|
}
|
|
|
|
}
|
2019-07-01 23:15:45 +01:00
|
|
|
|
2019-07-29 18:57:40 +01:00
|
|
|
func TestQuery(t *testing.T) {
|
2020-08-25 13:44:41 +03:00
|
|
|
table, route := testSetup(t)
|
2019-07-01 23:15:45 +01:00
|
|
|
|
2020-01-16 12:48:36 +00:00
|
|
|
svc := []string{"svc1", "svc2", "svc3", "svc1"}
|
|
|
|
net := []string{"net1", "net2", "net1", "net3"}
|
|
|
|
gw := []string{"gw1", "gw2", "gw3", "gw3"}
|
|
|
|
rtr := []string{"rtr1", "rt2", "rt3", "rtr3"}
|
2019-07-01 23:15:45 +01:00
|
|
|
|
2019-07-09 15:45:42 +01:00
|
|
|
for i := 0; i < len(svc); i++ {
|
|
|
|
route.Service = svc[i]
|
2019-07-08 21:03:54 +01:00
|
|
|
route.Network = net[i]
|
2019-07-09 15:45:42 +01:00
|
|
|
route.Gateway = gw[i]
|
2019-08-27 23:08:35 +01:00
|
|
|
route.Router = rtr[i]
|
2020-08-14 23:51:52 +01:00
|
|
|
route.Link = router.DefaultLink
|
|
|
|
|
2019-07-10 17:46:22 +01:00
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2019-07-01 23:15:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-08 21:03:54 +01:00
|
|
|
// return all routes
|
2019-10-09 17:13:52 +01:00
|
|
|
routes, err := table.Query()
|
2019-07-01 23:15:45 +01:00
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2019-12-03 22:59:44 +03:00
|
|
|
} else if len(routes) == 0 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: not found")
|
2019-07-01 23:15:45 +01:00
|
|
|
}
|
|
|
|
|
2019-08-27 23:08:35 +01:00
|
|
|
// query routes particular network
|
|
|
|
network := "net1"
|
2019-07-08 21:03:54 +01:00
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
routes, err = table.Query(router.QueryNetwork(network))
|
2019-07-08 21:03:54 +01:00
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(routes) != 2 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 2, len(routes))
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
2019-08-27 23:08:35 +01:00
|
|
|
for _, route := range routes {
|
|
|
|
if route.Network != network {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect route returned. Expected network: %s, found: %s", network, route.Network)
|
2019-08-27 23:08:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// query routes for particular gateway
|
2019-07-09 15:45:42 +01:00
|
|
|
gateway := "gw1"
|
2019-07-08 21:03:54 +01:00
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
routes, err = table.Query(router.QueryGateway(gateway))
|
2019-07-08 21:03:54 +01:00
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(routes) != 1 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 1, len(routes))
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
2019-07-09 15:45:42 +01:00
|
|
|
if routes[0].Gateway != gateway {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect route returned. Expected gateway: %s, found: %s", gateway, routes[0].Gateway)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
2019-08-27 23:08:35 +01:00
|
|
|
// query routes for particular router
|
2020-07-27 13:22:00 +01:00
|
|
|
rt := "rtr1"
|
2019-08-27 23:08:35 +01:00
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
routes, err = table.Query(router.QueryRouter(rt))
|
2019-08-27 23:08:35 +01:00
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2019-08-27 23:08:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(routes) != 1 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 1, len(routes))
|
2019-08-27 23:08:35 +01:00
|
|
|
}
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
if routes[0].Router != rt {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect route returned. Expected router: %s, found: %s", rt, routes[0].Router)
|
2019-08-27 23:08:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// query particular gateway and network
|
2020-07-27 13:22:00 +01:00
|
|
|
query := []router.QueryOption{
|
|
|
|
router.QueryGateway(gateway),
|
|
|
|
router.QueryNetwork(network),
|
|
|
|
router.QueryRouter(rt),
|
2019-10-09 17:13:52 +01:00
|
|
|
}
|
2019-07-08 21:03:54 +01:00
|
|
|
|
2019-10-09 17:13:52 +01:00
|
|
|
routes, err = table.Query(query...)
|
2019-07-08 21:03:54 +01:00
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(routes) != 1 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 1, len(routes))
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
2019-07-09 15:45:42 +01:00
|
|
|
if routes[0].Gateway != gateway {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect route returned. Expected gateway: %s, found: %s", gateway, routes[0].Gateway)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if routes[0].Network != network {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect network returned. Expected network: %s, found: %s", network, routes[0].Network)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
if routes[0].Router != rt {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect route returned. Expected router: %s, found: %s", rt, routes[0].Router)
|
2019-08-27 23:08:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// non-existen route query
|
2020-07-27 13:22:00 +01:00
|
|
|
routes, err = table.Query(router.QueryService("foobar"))
|
|
|
|
if err != router.ErrRouteNotFound {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes. Expected: %s, found: %s", router.ErrRouteNotFound, err)
|
2019-07-08 21:03:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(routes) != 0 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 0, len(routes))
|
2019-07-01 23:15:45 +01:00
|
|
|
}
|
2020-01-16 12:48:36 +00:00
|
|
|
|
|
|
|
// query NO routes
|
2020-07-27 13:22:00 +01:00
|
|
|
query = []router.QueryOption{
|
|
|
|
router.QueryGateway(gateway),
|
|
|
|
router.QueryNetwork(network),
|
2020-08-14 23:51:52 +01:00
|
|
|
router.QueryLink("network"),
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
routes, err = table.Query(query...)
|
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(routes) > 0 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 0, len(routes))
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// insert local routes to query
|
|
|
|
for i := 0; i < 2; i++ {
|
2020-08-14 23:51:52 +01:00
|
|
|
route.Link = "foobar"
|
2020-01-16 12:48:36 +00:00
|
|
|
route.Address = fmt.Sprintf("local.route.address-%d", i)
|
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// query local routes
|
2020-07-27 13:22:00 +01:00
|
|
|
query = []router.QueryOption{
|
|
|
|
router.QueryGateway("*"),
|
|
|
|
router.QueryNetwork("*"),
|
2020-08-14 23:51:52 +01:00
|
|
|
router.QueryLink("foobar"),
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
routes, err = table.Query(query...)
|
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(routes) != 2 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 2, len(routes))
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add two different routes for svcX with different metric
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
route.Service = "svcX"
|
|
|
|
route.Address = fmt.Sprintf("svcX.route.address-%d", i)
|
|
|
|
route.Metric = int64(100 + i)
|
2020-08-14 23:51:52 +01:00
|
|
|
route.Link = router.DefaultLink
|
2020-01-16 12:48:36 +00:00
|
|
|
if err := table.Create(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error adding route: %s", err)
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
query = []router.QueryOption{
|
|
|
|
router.QueryService("svcX"),
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
routes, err = table.Query(query...)
|
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up routes: %s", err)
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
|
|
|
|
2020-08-14 23:51:52 +01:00
|
|
|
if len(routes) != 2 {
|
|
|
|
t.Fatalf("incorrect number of routes returned. Expected: %d, found: %d", 1, len(routes))
|
2020-01-16 12:48:36 +00:00
|
|
|
}
|
2019-07-01 23:15:45 +01:00
|
|
|
}
|
2020-07-01 15:20:30 +01:00
|
|
|
|
|
|
|
func TestFallback(t *testing.T) {
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
r := &rtr{
|
2020-08-14 23:51:52 +01:00
|
|
|
options: router.DefaultOptions(),
|
2020-07-01 15:20:30 +01:00
|
|
|
}
|
2020-07-27 13:22:00 +01:00
|
|
|
route := router.Route{
|
2020-07-01 15:20:30 +01:00
|
|
|
Service: "go.micro.service.foo",
|
|
|
|
Router: r.options.Id,
|
2020-07-27 13:22:00 +01:00
|
|
|
Link: router.DefaultLink,
|
|
|
|
Metric: router.DefaultLocalMetric,
|
2020-07-01 15:20:30 +01:00
|
|
|
}
|
2020-08-07 20:53:38 +01:00
|
|
|
r.table = newTable(func(s string) ([]router.Route, error) {
|
|
|
|
return []router.Route{route}, nil
|
2020-07-01 15:20:30 +01:00
|
|
|
})
|
|
|
|
r.start()
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
rts, err := r.Lookup(router.QueryService("go.micro.service.foo"))
|
2020-07-01 15:20:30 +01:00
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up service %s", err)
|
2020-07-01 15:20:30 +01:00
|
|
|
}
|
|
|
|
if len(rts) != 1 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned %d", len(rts))
|
2020-07-01 15:20:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// deleting from the table but the next query should invoke the fallback that we passed during new table creation
|
|
|
|
if err := r.table.Delete(route); err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error deleting route %s", err)
|
2020-07-01 15:20:30 +01:00
|
|
|
}
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
rts, err = r.Lookup(router.QueryService("go.micro.service.foo"))
|
2020-07-01 15:20:30 +01:00
|
|
|
if err != nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("error looking up service %s", err)
|
2020-07-01 15:20:30 +01:00
|
|
|
}
|
|
|
|
if len(rts) != 1 {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("incorrect number of routes returned %d", len(rts))
|
2020-07-01 15:20:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-07-02 18:29:11 +01:00
|
|
|
|
|
|
|
func TestFallbackError(t *testing.T) {
|
2020-07-27 13:22:00 +01:00
|
|
|
r := &rtr{
|
2020-08-14 23:51:52 +01:00
|
|
|
options: router.DefaultOptions(),
|
2020-07-02 18:29:11 +01:00
|
|
|
}
|
2020-08-07 20:53:38 +01:00
|
|
|
r.table = newTable(func(s string) ([]router.Route, error) {
|
|
|
|
return nil, fmt.Errorf("ERROR")
|
2020-07-02 18:29:11 +01:00
|
|
|
})
|
|
|
|
r.start()
|
2020-07-27 13:22:00 +01:00
|
|
|
_, err := r.Lookup(router.QueryService("go.micro.service.foo"))
|
2020-07-02 18:29:11 +01:00
|
|
|
if err == nil {
|
2020-08-14 23:51:52 +01:00
|
|
|
t.Fatalf("expected error looking up service but none returned")
|
2020-07-02 18:29:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|