From 0dd605fbd2a8e64c7c84a244ce14f41b688f52c8 Mon Sep 17 00:00:00 2001 From: Guillaume Rose Date: Wed, 13 Oct 2021 09:10:00 +0200 Subject: [PATCH] Check error is not nil before calling a function on it --- test/port_forwarding_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/port_forwarding_test.go b/test/port_forwarding_test.go index 1e85f52be..b8685d97e 100644 --- a/test/port_forwarding_test.go +++ b/test/port_forwarding_test.go @@ -54,6 +54,7 @@ var _ = Describe("port forwarding", func() { }() _, err = net.Dial("tcp", "127.0.0.1:9090") + Expect(err).Should(HaveOccurred()) Expect(err.Error()).To(HaveSuffix("connection refused")) Expect(client.Expose(&types.ExposeRequest{ @@ -73,6 +74,7 @@ var _ = Describe("port forwarding", func() { Eventually(func(g Gomega) { _, err = net.Dial("tcp", "127.0.0.1:9090") + g.Expect(err).Should(HaveOccurred()) g.Expect(err.Error()).To(HaveSuffix("connection refused")) }).Should(Succeed()) }) @@ -151,6 +153,7 @@ address=/foobar/1.2.3.4 }() _, err = net.Dial("tcp", "127.0.0.1:9090") + Expect(err).Should(HaveOccurred()) Expect(err.Error()).To(HaveSuffix("connection refused")) _, err = sshExec(`curl http://gateway.containers.internal/services/forwarder/expose -X POST -d'{"local":":9090", "remote":":8080"}'`) @@ -167,6 +170,7 @@ address=/foobar/1.2.3.4 Eventually(func(g Gomega) { _, err = net.Dial("tcp", "127.0.0.1:9090") + g.Expect(err).Should(HaveOccurred()) g.Expect(err.Error()).To(HaveSuffix("connection refused")) }).Should(Succeed()) })