go-kratos--kratos
6cf6f95f58
CodeQL / Analyze (push) Has been cancelled
Sync to Gitee / Run (push) Has been cancelled
Go / build & test (1.25.x) (push) Has been cancelled
Go / build & test (1.26.x) (push) Has been cancelled
Lint / resolve module (push) Has been cancelled
Lint / lint module (push) Has been cancelled
25 行
404 B
Go
25 行
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!")
|
|
}
|
|
}
|