nuclei/v2/pkg/reporting/dedupe/dedupe_test.go
Mzack9999 30054d1fb6
Adding advanced template filtering (#2374)
* Adding advanced template filtering

* fixing bug in slice

* refactoring tests

* adding test cases

* increasing error verbosity

* fixing quoted fields with spaces

* adding more test cases

* fixing merge error

* fixing lint errors

* switching to []string

* updating tag filter tests

* updating functional tests

* fixing functional test cases

* updating syntax
2022-08-25 16:52:08 +05:30

32 lines
827 B
Go

package dedupe
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/projectdiscovery/nuclei/v2/pkg/output"
)
func TestDedupeDuplicates(t *testing.T) {
tempDir, err := os.MkdirTemp("", "nuclei")
require.Nil(t, err, "could not create temporary storage")
defer os.RemoveAll(tempDir)
storage, err := New(tempDir)
require.Nil(t, err, "could not create duplicate storage")
tests := []*output.ResultEvent{
{TemplateID: "test", Host: "https://example.com"},
{TemplateID: "test", Host: "https://example.com"},
}
first, err := storage.Index(tests[0])
require.Nil(t, err, "could not index item")
require.True(t, first, "could not index valid item")
second, err := storage.Index(tests[1])
require.Nil(t, err, "could not index item")
require.False(t, second, "could index duplicate item")
}