package main import ( "context" "testing" ) func TestQAOpsConnectionFailureIsContainedOutsideMainDatabase(t *testing.T) { reader, settings := openQAOperations(context.Background(), func(string) string { return "" }, "postgres://main@host/governance", nil) if reader != nil || settings.Enabled || settings.Problem != "" { t.Fatal("QA operations must be disabled by default") } env := map[string]string{"DOBOTAI_OPS_READ_ENABLED": "true", "DOBOTAI_OPS_TENANT_KEY": "approved-tenant", "DOBOTAI_OPS_READ_DSN_FILE": "/nonexistent-qaops-fixture-secret"} reader, settings = openQAOperations(context.Background(), func(k string) string { return env[k] }, "postgres://main@host/governance", nil) if reader == nil || !settings.Enabled || settings.Problem != "" { t.Fatal("API serving still constructs a source connection instead of a local reader") } }