package recon import ( "context" "testing" "github.com/stretchr/testify/require" ) func TestRegisterList(t *testing.T) { e := NewEngine() require.Empty(t, e.List()) e.Register(ExampleSource{}) require.Equal(t, []string{"example"}, e.List()) // Re-registering the same name is idempotent. e.Register(ExampleSource{}) require.Equal(t, []string{"example"}, e.List()) } func TestSweepAll(t *testing.T) { e := NewEngine() e.Register(ExampleSource{}) findings, err := e.SweepAll(context.Background(), Config{Query: "ignored"}) require.NoError(t, err) require.Len(t, findings, 2, "ExampleSource should emit exactly 2 deterministic findings") for _, f := range findings { require.Equal(t, "recon:example", f.SourceType) require.NotEmpty(t, f.ProviderName) require.NotEmpty(t, f.KeyMasked) require.NotEmpty(t, f.Source) } } func TestSweepAll_NoSources(t *testing.T) { e := NewEngine() findings, err := e.SweepAll(context.Background(), Config{}) require.NoError(t, err) require.Nil(t, findings) } // disabledSource tests that Enabled() filtering works. type disabledSource struct{ ExampleSource } func (disabledSource) Name() string { return "disabled" } func (disabledSource) Enabled(Config) bool { return false } func TestSweepAll_FiltersDisabled(t *testing.T) { e := NewEngine() e.Register(disabledSource{}) findings, err := e.SweepAll(context.Background(), Config{}) require.NoError(t, err) require.Empty(t, findings) }