Fix socket leak, clean up single use postgres databases (#2413)

* Fix socket leak, clean up single use postgres databases

Signed-off-by: Spike Curtis <spike@coder.com>

* Move migrate close defer until after we know it is not nil

Signed-off-by: Spike Curtis <spike@coder.com>
This commit is contained in:
Spike Curtis
2022-06-16 09:01:33 -07:00
committed by GitHub
parent eab5c15062
commit a82c0eb560
4 changed files with 38 additions and 9 deletions
+6 -4
View File
@@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
@@ -30,13 +30,15 @@ func TestList(t *testing.T) {
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
errC := make(chan error)
done := make(chan any)
go func() {
errC <- cmd.ExecuteContext(ctx)
errC := cmd.ExecuteContext(ctx)
assert.NoError(t, errC)
close(done)
}()
pty.ExpectMatch(workspace.Name)
pty.ExpectMatch("Running")
cancelFunc()
require.NoError(t, <-errC)
<-done
})
}