Files
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

45 lines
1.8 KiB
Go

package config
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestExternalCallSynthesis_AbsentIsDefaultOn asserts that a config with
// no `synthesize_external_calls` key leaves the pointer nil — which the
// tri-state resolver reads as "external-call qualification ON" — so every
// external call gets a stable cross-repo identity node by default
// (affordable because synthesis is incremental on the hot path).
func TestExternalCallSynthesis_AbsentIsDefaultOn(t *testing.T) {
cfg, err := Load(writeConfig(t, "index:\n workers: 2\n"))
require.NoError(t, err)
assert.Nil(t, cfg.Index.SynthesizeExternalCalls,
"an absent key must leave the pointer nil (not false) so default-on applies")
assert.True(t, cfg.Index.ExternalCallSynthesisEnabledOrDefault(),
"a nil flag must resolve to ON")
}
// TestExternalCallSynthesis_ExplicitlyDisabled asserts an explicit
// opt-out is distinguishable from "absent" and turns synthesis off.
func TestExternalCallSynthesis_ExplicitlyDisabled(t *testing.T) {
cfg, err := Load(writeConfig(t, "index:\n synthesize_external_calls: false\n"))
require.NoError(t, err)
require.NotNil(t, cfg.Index.SynthesizeExternalCalls, "an explicit value must round-trip as a non-nil pointer")
assert.False(t, *cfg.Index.SynthesizeExternalCalls)
assert.False(t, cfg.Index.ExternalCallSynthesisEnabledOrDefault())
}
// TestExternalCallSynthesis_ExplicitlyEnabled asserts `true` round-trips.
func TestExternalCallSynthesis_ExplicitlyEnabled(t *testing.T) {
cfg, err := Load(writeConfig(t, "index:\n synthesize_external_calls: true\n"))
require.NoError(t, err)
require.NotNil(t, cfg.Index.SynthesizeExternalCalls)
assert.True(t, *cfg.Index.SynthesizeExternalCalls)
assert.True(t, cfg.Index.ExternalCallSynthesisEnabledOrDefault())
}