Files
zzet--gortex/internal/semantic/enrichment_active_test.go
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

38 lines
1.5 KiB
Go

package semantic
import (
"testing"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
)
// EnrichmentActive must report true while any (repo, provider) pass is
// in the running state and false once every pass has settled — the
// signal the local-model load gate reads to defer a cold load.
func TestEnrichmentActive(t *testing.T) {
mgr := NewManager(Config{Enabled: true}, zap.NewNop())
// No passes recorded yet.
assert.False(t, mgr.EnrichmentActive(), "an idle manager must report EnrichmentActive=false")
// A running pass flips it true.
mgr.setEnrichStatus("repo-a", "gopls", "go", EnrichStateRunning, 0, nil, "")
assert.True(t, mgr.EnrichmentActive(), "a running pass must report EnrichmentActive=true")
// A second, completed pass on another repo doesn't change the answer:
// repo-a is still running.
mgr.setEnrichStatus("repo-b", "gopls", "go", EnrichStateCompleted, 0, nil, "")
assert.True(t, mgr.EnrichmentActive(), "one still-running pass keeps EnrichmentActive=true")
// repo-a completing settles everything.
mgr.setEnrichStatus("repo-a", "gopls", "go", EnrichStateCompleted, 0, nil, "")
assert.False(t, mgr.EnrichmentActive(), "with no running pass EnrichmentActive must be false")
// Terminal non-running states never read as active.
for _, state := range []string{EnrichStatePartial, EnrichStateAbandoned, EnrichStateFailed} {
mgr.setEnrichStatus("repo-a", "gopls", "go", state, 0, nil, "")
assert.Falsef(t, mgr.EnrichmentActive(), "state %q must not read as active", state)
}
}