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

Function TestPoolReplaceProvidersAfterShutdownIsNoop

coderd/aibridged/pool_test.go:246–269  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

244}
245
246func TestPoolReplaceProvidersAfterShutdownIsNoop(t *testing.T) {
247 t.Parallel()
248
249 logger := slogtest.Make(t, nil)
250 opts := aibridged.PoolOptions{MaxItems: 1, TTL: time.Minute}
251 pool, err := aibridged.NewCachedBridgePool(opts, nil, logger, nil, testTracer)
252 require.NoError(t, err)
253
254 require.NoError(t, pool.Shutdown(t.Context()))
255 require.NotPanics(t, func() {
256 pool.ReplaceProviders([]aibridge.Provider{
257 aibridge.NewOpenAIProvider(config.OpenAI{Name: "new", BaseURL: "https://example.com"}),
258 })
259 })
260
261 _, err = pool.Acquire(t.Context(), aibridged.Request{
262 SessionKey: "key",
263 InitiatorID: uuid.New(),
264 APIKeyID: uuid.New().String(),
265 }, func() (aibridged.DRPCClient, error) {
266 return nil, context.Canceled
267 }, newMockMCPFactory(nil))
268 require.ErrorContains(t, err, "pool shutting down")
269}
270
271func TestPool_Expiry(t *testing.T) {
272 t.Parallel()

Callers

nothing calls this directly

Calls 9

ShutdownMethod · 0.95
ReplaceProvidersMethod · 0.95
AcquireMethod · 0.95
NewCachedBridgePoolFunction · 0.92
NewOpenAIProviderFunction · 0.92
newMockMCPFactoryFunction · 0.85
ContextMethod · 0.65
NewMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected