MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestLoad_ExpandsEnvVarsInYAML

Function TestLoad_ExpandsEnvVarsInYAML

internal/config/config_test.go:444–474  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

442}
443
444func TestLoad_ExpandsEnvVarsInYAML(t *testing.T) {
445 t.Setenv("OPENAI_API_KEY", "sk-from-env")
446 cfgPath := writeTempConfig(t, `
447server:
448 port: 8080
449backends:
450 - name: oa
451 type: openai_compatible
452 endpoint: https://api.example.com
453 timeout_ms: 100
454 api_key: ${OPENAI_API_KEY}
455 health_path: /v1/models
456 default_model: gpt-4o-mini
457 cost: { unit: 1, currency: credit }
458 capabilities: [chat]
459tenants:
460 - id: t1
461routing:
462 default_backend: oa
463reliability:
464 fallback_enabled: false
465`)
466
467 cfg, err := Load(cfgPath)
468 if err != nil {
469 t.Fatalf("expected config to load: %v", err)
470 }
471 if cfg.Backends[0].APIKey != "sk-from-env" {
472 t.Fatalf("api_key after expand: %q", cfg.Backends[0].APIKey)
473 }
474}
475
476func TestLoad_ServerHTTPTimeoutsNegative(t *testing.T) {
477 cfgPath := writeTempConfig(t, `

Callers

nothing calls this directly

Calls 2

writeTempConfigFunction · 0.85
LoadFunction · 0.85

Tested by

no test coverage detected