MCPcopy Index your code
hub / github.com/coder/coder / TestPubSub_DoesntBlockNotify

Function TestPubSub_DoesntBlockNotify

coderd/database/pubsub/pubsub_internal_test.go:16–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestPubSub_DoesntBlockNotify(t *testing.T) {
17 t.Parallel()
18 ctx := testutil.Context(t, testutil.WaitShort)
19 logger := testutil.Logger(t)
20
21 uut := newWithoutListener(logger, nil)
22 fListener := newFakePqListener()
23 uut.pgListener = fListener
24 go uut.listen()
25
26 cancels := make(chan func())
27 go func() {
28 subCancel, err := uut.Subscribe("bagels", func(ctx context.Context, message []byte) {
29 t.Logf("got message: %s", string(message))
30 })
31 assert.NoError(t, err)
32 cancels <- subCancel
33 }()
34 subCancel := testutil.TryReceive(ctx, t, cancels)
35 cancelDone := make(chan struct{})
36 go func() {
37 defer close(cancelDone)
38 subCancel()
39 }()
40 testutil.TryReceive(ctx, t, cancelDone)
41
42 closeErrs := make(chan error)
43 go func() {
44 closeErrs <- uut.Close()
45 }()
46 err := testutil.TryReceive(ctx, t, closeErrs)
47 require.NoError(t, err)
48}
49
50// TestPubSub_DoesntRaceListenUnlisten tests for regressions of
51// https://github.com/coder/coder/issues/15312

Callers

nothing calls this directly

Calls 9

ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
newWithoutListenerFunction · 0.85
newFakePqListenerFunction · 0.85
SubscribeMethod · 0.65
LogfMethod · 0.65
CloseMethod · 0.65
listenMethod · 0.45

Tested by

no test coverage detected