forked from projectdiscovery/nuclei
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdedupe_test.go
31 lines (24 loc) · 827 Bytes
/
dedupe_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package dedupe
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/projectdiscovery/nuclei/v3/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")
}