🐞 Make integration tests more robust

I'd assert that the server had exited with a 1 (error condition) when it
couldn't bind via UDP to any addresses; however, I wrote the expectation
wrong, and sometimes the server hadn't exited by the time I made the
assertion, resulting in an exit code of -1 (not yet exited) instead of
1.

Using an async assertion `Eventually()`, with a switch `ExitCode()` →
`Exit()`, fixes that problem.

Fixes, during `ginkgo -r -p`:
```
  [FAILED] Expected
      <int>: -1
  to equal
      <int>: 1
  In [It] at: /home/cunnie/workspace/sslip.io/src/sslip.io-dns-server/integration_test.go:400 @ 10/02/23 03:58:15.824
```
This commit is contained in:
Brian Cunnie
2023-10-02 04:08:01 -07:00
parent ce94dfc20b
commit 2df94a4352

View File

@@ -397,7 +397,7 @@ var _ = Describe("sslip.io-dns-server", func() {
secondServerSession, err := Start(secondServerCmd, GinkgoWriter, GinkgoWriter) secondServerSession, err := Start(secondServerCmd, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Eventually(secondServerSession.Err, 10).Should(Say("I couldn't bind via UDP to any IPs")) Eventually(secondServerSession.Err, 10).Should(Say("I couldn't bind via UDP to any IPs"))
Expect(secondServerSession.ExitCode()).To(Equal(1)) Eventually(secondServerSession).Should(Exit(1))
}) })
}) })
When("it can't bind to any TCP port", func() { When("it can't bind to any TCP port", func() {