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.
This commit is contained in:
Spike Curtis
2023-12-21 14:26:11 +04:00
committed by GitHub
parent fe867d02e0
commit db9104c02e
+4 -3
View File
@@ -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