From c33d1609af3d698e1855a441b7230d08e2715be1 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Fri, 24 Jul 2015 11:39:27 -0700 Subject: [PATCH] refactor a bit --- test/end2end_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/end2end_test.go b/test/end2end_test.go index 9b541e6e..8d7eac83 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -72,11 +72,10 @@ func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.E if md, ok := metadata.FromContext(ctx); ok { // For testing purpose, returns an error if there is attached metadata other than // the user agent set by the client application. - if ua, isOK := md["user-agent"]; isOK { - grpc.SendHeader(ctx, metadata.Pairs("ua", ua)) - } else { + if _, ok := md["user-agent"]; !ok { return nil, grpc.Errorf(codes.DataLoss, "got extra metadata") } + grpc.SendHeader(ctx, metadata.Pairs("ua", md["user-agent"])) } return new(testpb.Empty), nil }