chore(provisionerd): close completeChan exactly once (#16011)

Fixes https://github.com/coder/internal/issues/263
This commit is contained in:
Cian Johnston
2025-01-02 15:14:06 +00:00
committed by GitHub
parent 9c625476b7
commit 82070944f1
+4 -1
View File
@@ -70,8 +70,11 @@ func TestProvisionerd(t *testing.T) {
close(done)
})
completeChan := make(chan struct{})
var completed sync.Once
closer := createProvisionerd(t, func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
defer close(completeChan)
completed.Do(func() {
defer close(completeChan)
})
return nil, xerrors.New("an error")
}, provisionerd.LocalProvisioners{})
require.Condition(t, closedWithin(completeChan, testutil.WaitShort))