From 2df94a43526859b10a49ab5e18fdb44160021437 Mon Sep 17 00:00:00 2001 From: Brian Cunnie Date: Mon, 2 Oct 2023 04:08:01 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Make=20integration=20tests=20mor?= =?UTF-8?q?e=20robust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 : -1 to equal : 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 ``` --- src/sslip.io-dns-server/integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sslip.io-dns-server/integration_test.go b/src/sslip.io-dns-server/integration_test.go index da0fe10..4725161 100644 --- a/src/sslip.io-dns-server/integration_test.go +++ b/src/sslip.io-dns-server/integration_test.go @@ -397,7 +397,7 @@ var _ = Describe("sslip.io-dns-server", func() { secondServerSession, err := Start(secondServerCmd, GinkgoWriter, GinkgoWriter) Expect(err).ToNot(HaveOccurred()) 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() {