From 304f44c041a8ffd063eb44322b3827a1a478f9cb Mon Sep 17 00:00:00 2001 From: Henry Snopek Date: Fri, 21 Oct 2022 18:47:50 -0500 Subject: [PATCH] refactor: t.Error + return -> t.Fatal --- wait/http_test.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/wait/http_test.go b/wait/http_test.go index 93e11ae40d..5e8e1937ff 100644 --- a/wait/http_test.go +++ b/wait/http_test.go @@ -48,21 +48,18 @@ func ExampleHTTPStrategy() { func TestHTTPStrategyWaitUntilReady(t *testing.T) { workdir, err := os.Getwd() if err != nil { - t.Error(err) - return + t.Fatal(err) } capath := path.Join(workdir, "testdata", "root.pem") cafile, err := os.ReadFile(capath) if err != nil { - t.Errorf("can't load ca file: %v", err) - return + t.Fatalf("can't load ca file: %v", err) } certpool := x509.NewCertPool() if !certpool.AppendCertsFromPEM(cafile) { - t.Errorf("the ca file isn't valid") - return + t.Fatalf("the ca file isn't valid") } tlsconfig := &tls.Config{RootCAs: certpool, ServerName: "testcontainer.go.test"} @@ -88,20 +85,17 @@ func TestHTTPStrategyWaitUntilReady(t *testing.T) { ctx := context.Background() container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ContainerRequest: dockerReq, Started: true}) if err != nil { - t.Error(err) - return + t.Fatal(err) } testcontainers.CleanupContainer(t, ctx, container) host, err := container.Host(ctx) if err != nil { - t.Error(err) - return + t.Fatal(err) } port, err := container.MappedPort(ctx, "6443/tcp") if err != nil { - t.Error(err) - return + t.Fatal(err) } client := http.Client{ Transport: &http.Transport{ @@ -121,12 +115,10 @@ func TestHTTPStrategyWaitUntilReady(t *testing.T) { } resp, err := client.Get(fmt.Sprintf("https://%s:%s", host, port.Port())) if err != nil { - t.Error(err) - return + t.Fatal(err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - t.Errorf("status code isn't ok: %s", resp.Status) - return + t.Fatalf("status code isn't ok: %s", resp.Status) } }