Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check error is not nil before calling a function on it #64

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/port_forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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())
})
Expand Down Expand Up @@ -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"}'`)
Expand All @@ -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())
})
Expand Down