2021-02-19 23:12:48 +03:00
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
package mdns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-10-27 23:49:50 +03:00
|
|
|
registry "go.unistack.org/micro/v3/register"
|
2021-02-19 23:12:48 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
svc1 = ®istry.Service{
|
|
|
|
Name: "foo",
|
|
|
|
Version: "latest",
|
|
|
|
Nodes: []*registry.Node{
|
|
|
|
®istry.Node{
|
|
|
|
Id: "1",
|
|
|
|
Address: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestServer_StartStop(t *testing.T) {
|
|
|
|
//s := makeService(t)
|
|
|
|
srv, err := NewServer(&Config{})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if err = srv.Shutdown(); err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestServer_Lookup(t *testing.T) {
|
|
|
|
srv1, err := NewServer(&Config{})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
defer srv1.Shutdown()
|
|
|
|
/*
|
|
|
|
srv2, err := NewServer(&Config{})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
defer srv2.Shutdown()
|
|
|
|
*/
|
|
|
|
if err = srv1.Register(svc1); err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
select {}
|
|
|
|
services, err := srv2.GetService("foo")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
} else if len(services) == 0 {
|
|
|
|
t.Fatalf("empty service")
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, svc := range services {
|
|
|
|
fmt.Printf("%#+v\n", svc)
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
select {}
|
|
|
|
}
|