change error information

This commit is contained in:
yangzhouhan
2015-07-23 17:14:27 -07:00
parent e9dfeb65b7
commit a5348d9bde

View File

@ -383,7 +383,7 @@ func testHealthCheckOnSuccess(t *testing.T, e env) {
s, cc := setUp(hs, math.MaxUint32, e) s, cc := setUp(hs, math.MaxUint32, e)
defer tearDown(s, cc) defer tearDown(s, cc)
if _, err := healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck"); err != nil { if _, err := healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck"); err != nil {
t.Fatalf("TestHealthCheck(_)=_, %v, want <nil>", err) t.Fatalf("HealthCheck/Check(,_)= _, %v, want <nil>", err)
} }
} }
@ -399,7 +399,7 @@ func testHealthCheckOnFailure(t *testing.T, e env) {
s, cc := setUp(hs, math.MaxUint32, e) s, cc := setUp(hs, math.MaxUint32, e)
defer tearDown(s, cc) defer tearDown(s, cc)
if _, err := healthCheck(0*time.Second, cc, "grpc.health.v1alpha.HealthCheck"); err != grpc.Errorf(codes.DeadlineExceeded, "context deadline exceeded") { if _, err := healthCheck(0*time.Second, cc, "grpc.health.v1alpha.HealthCheck"); err != grpc.Errorf(codes.DeadlineExceeded, "context deadline exceeded") {
t.Fatalf("TestHealthCheck(_)=_, %v, want error code %d", err, codes.DeadlineExceeded) t.Fatalf("HealthCheck/Check(,_)= _, %v, want error code %d", err, codes.DeadlineExceeded)
} }
} }
@ -413,7 +413,7 @@ func testHealthCheckOff(t *testing.T, e env) {
s, cc := setUp(nil, math.MaxUint32, e) s, cc := setUp(nil, math.MaxUint32, e)
defer tearDown(s, cc) defer tearDown(s, cc)
if _, err := healthCheck(1*time.Second, cc, ""); err != grpc.Errorf(codes.Unimplemented, "unknown service grpc.health.v1alpha.HealthCheck") { if _, err := healthCheck(1*time.Second, cc, ""); err != grpc.Errorf(codes.Unimplemented, "unknown service grpc.health.v1alpha.HealthCheck") {
t.Fatalf("TestHealthCheck(_)=_, %v, want error code %d", err, codes.Unimplemented) t.Fatalf("HealthCheck/Check(,_) = _, %v, want error code %d", err, codes.Unimplemented)
} }
} }
@ -428,20 +428,20 @@ func testHealthCheckServingStatus(t *testing.T, e env) {
s, cc := setUp(hs, math.MaxUint32, e) s, cc := setUp(hs, math.MaxUint32, e)
defer tearDown(s, cc) defer tearDown(s, cc)
if _, err := healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck"); err != grpc.Errorf(codes.NotFound, "unknown service") { if _, err := healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck"); err != grpc.Errorf(codes.NotFound, "unknown service") {
t.Fatalf("TestHealthCheck(_)=_, %v, want error code %d", err, codes.NotFound) t.Fatalf("HealthCheck/Check(,_)= _, %v, want error code %d", err, codes.NotFound)
} }
hs.SetServingStatus("", "grpc.health.v1alpha.HealthCheck", 1) hs.SetServingStatus("", "grpc.health.v1alpha.HealthCheck", int32(healthpb.HealthCheckResponse_SERVING))
out, err := healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck") out, err := healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck")
if err != nil { if err != nil {
t.Fatalf("TestHealthCheck(_)=_, %v, want _,<nil>", err) t.Fatalf("HealthCheck/Check(,_)= _, %v, want _,<nil>", err)
} }
if out.Status != healthpb.HealthCheckResponse_SERVING { if out.Status != healthpb.HealthCheckResponse_SERVING {
t.Fatalf("Got the serving status %v, want SERVING", out.Status) t.Fatalf("Got the serving status %v, want SERVING", out.Status)
} }
hs.SetServingStatus("", "grpc.health.v1alpha.HealthCheck", 2) hs.SetServingStatus("", "grpc.health.v1alpha.HealthCheck", int32(healthpb.HealthCheckResponse_NOT_SERVING))
out, err = healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck") out, err = healthCheck(1*time.Second, cc, "grpc.health.v1alpha.HealthCheck")
if err != nil { if err != nil {
t.Fatalf("TestHealthCheck(_)=_, %v, want _,<nil>", err) t.Fatalf("HealthCheck/Check(,_)= _, %v, want _,<nil>", err)
} }
if out.Status != healthpb.HealthCheckResponse_NOT_SERVING { if out.Status != healthpb.HealthCheckResponse_NOT_SERVING {
t.Fatalf("Got the serving status %v, want NOT_SERVING ") t.Fatalf("Got the serving status %v, want NOT_SERVING ")