test: add more tests (#1147)

* test: add more tests

* test: add more tests
This commit is contained in:
Kevin Wan
2021-10-19 22:37:56 +08:00
committed by GitHub
parent d41163f5c1
commit eab77e21dd
5 changed files with 112 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ const localhost = "127.0.0.1"
// PeerFromCtx returns the peer from ctx.
func PeerFromCtx(ctx context.Context) string {
p, ok := peer.FromContext(ctx)
if !ok {
if !ok || p == nil {
return ""
}
@@ -55,7 +55,7 @@ func ParseFullMethod(fullMethod string) (string, []attribute.KeyValue) {
func PeerAttr(addr string) []attribute.KeyValue {
host, port, err := net.SplitHostPort(addr)
if err != nil {
return []attribute.KeyValue(nil)
return nil
}
if len(host) == 0 {