From db9104c02e2437d01d2c3b886d65a909001ee0f9 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Thu, 21 Dec 2023 14:26:11 +0400 Subject: [PATCH] fix: avoid panic on nil connection (#11305) Related to https://github.com/coder/coder/actions/runs/7286675441/job/19855871305 Fixes a panic if the listener returns an error, which can obfuscate the underlying problem and cause unrelated tests to be marked failed. --- agent/agent_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index 69a4a1ac91..9017240738 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -1635,9 +1635,10 @@ func TestAgent_Dial(t *testing.T) { go func() { defer close(done) c, err := l.Accept() - assert.NoError(t, err, "accept connection") - defer c.Close() - testAccept(ctx, t, c) + if assert.NoError(t, err, "accept connection") { + defer c.Close() + testAccept(ctx, t, c) + } }() //nolint:dogsled