From 2c1d00e17111a8c685bf4f041bc964bea449b0fa Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Mon, 21 May 2018 18:39:25 +0200 Subject: [PATCH] Adjust error checking in tests --- client/http/http_client_test.go | 4 ++-- servers/grpc/grpc_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/http/http_client_test.go b/client/http/http_client_test.go index a4eb95a..baf83b1 100644 --- a/client/http/http_client_test.go +++ b/client/http/http_client_test.go @@ -94,7 +94,7 @@ func TestClientRetryFailure(t *testing.T) { }() r, err := New(&Options{RetryTimeMax: 1 * time.Second}).Get(fmt.Sprintf("http://localhost:%d", port)) - if err == nil || !strings.Contains(err.Error(), "getsockopt: connection refused") { + if err == nil || !strings.Contains(err.Error(), "connection refused") { t.Errorf("expected connection refused error, got %#v", err) } if r != nil { @@ -102,7 +102,7 @@ func TestClientRetryFailure(t *testing.T) { } r, err = (&http.Client{Transport: Transport(&Options{RetryTimeMax: 1 * time.Second})}).Get(fmt.Sprintf("http://localhost:%d", port)) - if err == nil || !strings.Contains(err.Error(), "getsockopt: connection refused") { + if err == nil || !strings.Contains(err.Error(), "connection refused") { t.Errorf("expected connection refused error, got %#v", err) } if r != nil { diff --git a/servers/grpc/grpc_test.go b/servers/grpc/grpc_test.go index 4b3911c..401b6c6 100644 --- a/servers/grpc/grpc_test.go +++ b/servers/grpc/grpc_test.go @@ -104,8 +104,8 @@ func TestServerShutdown(t *testing.T) { s.Shutdown(context.Background()) r, err = c.Greet(context.Background(), &hello.GreetRequest{Name: name}) - if err.Error() != "rpc error: code = Unavailable desc = all SubConns are in TransientFailure" { - t.Fatal(err) + if !strings.Contains(err.Error(), "connection refused") { + t.Fatalf("unexpected error: %q", err) } }