1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-14 02:33:03 +02:00
kratos/selector/peer_test.go
longxboy 123fc1e6c8
feat: add peer for selector (#2088)
* add peer for selector
2022-06-07 22:38:21 +08:00

25 lines
404 B
Go

package selector
import (
"context"
"testing"
)
func TestPeer(t *testing.T) {
p := Peer{
Node: mockWeightedNode{},
}
ctx := NewPeerContext(context.Background(), &p)
p2, ok := FromPeerContext(ctx)
if !ok || p2.Node == nil {
t.Fatalf(" no peer found!")
}
}
func TestNotPeer(t *testing.T) {
_, ok := FromPeerContext(context.Background())
if ok {
t.Fatalf("test no peer found peer!")
}
}