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

Function TestSubscribeProviderReload

coderd/aibridged/reload_test.go:18–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestSubscribeProviderReload(t *testing.T) {
19 t.Parallel()
20
21 ctx := testutil.Context(t, testutil.WaitMedium)
22
23 logger := slogtest.Make(t, nil)
24 ps := dbpubsub.NewInMemory()
25 t.Cleanup(func() { _ = ps.Close() })
26
27 calls := &recordingReloader{}
28
29 unsub, err := aibridged.SubscribeProviderReload(ctx, ps, calls, logger)
30 require.NoError(t, err)
31 t.Cleanup(unsub)
32
33 require.Equal(t, 1, calls.count())
34
35 require.NoError(t, ps.Publish(pubsub.AIProvidersChangedChannel, nil))
36
37 require.Eventually(t, func() bool { return calls.count() >= 2 }, testutil.WaitShort, testutil.IntervalFast,
38 "Reload must fire again after a pubsub notification")
39}
40
41func TestSubscribeProviderReloadSurfacesReloadError(t *testing.T) {
42 t.Parallel()

Callers

nothing calls this directly

Calls 7

countMethod · 0.95
ContextFunction · 0.92
SubscribeProviderReloadFunction · 0.92
CleanupMethod · 0.65
CloseMethod · 0.65
PublishMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected