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

Function buildFromEnv

cli/aibridged_internal_test.go:31–41  ·  view source on GitHub ↗

buildFromEnv exercises the same env-config-in/providers-out path that production uses on boot: SeedAIProvidersFromEnv writes the env-derived rows to the database, and BuildProviders reads them back as runtime [aibridge.Provider] instances. This keeps the existing TestBuildProviders table intact whil

(t *testing.T, cfg codersdk.AIBridgeConfig)

Source from the content-addressed store, hash-verified

29// table intact while reflecting the post-refactor flow where the database
30// is the single source of truth.
31func buildFromEnv(t *testing.T, cfg codersdk.AIBridgeConfig) ([]aibridge.Provider, error) {
32 t.Helper()
33 db, _ := dbtestutil.NewDB(t)
34 ctx := testutil.Context(t, testutil.WaitShort)
35 logger := slogtest.Make(t, nil)
36 if err := coderd.SeedAIProvidersFromEnv(ctx, db, cfg, logger); err != nil {
37 return nil, err
38 }
39 providers, _, err := BuildProviders(ctx, db, cfg, logger)
40 return providers, err
41}
42
43func TestBuildProviders(t *testing.T) {
44 t.Parallel()

Callers 1

TestBuildProvidersFunction · 0.85

Calls 5

NewDBFunction · 0.92
ContextFunction · 0.92
SeedAIProvidersFromEnvFunction · 0.92
BuildProvidersFunction · 0.85
HelperMethod · 0.65

Tested by

no test coverage detected