Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/operators/operators_test.go
2070 views
1
package operators
2
3
import (
4
"testing"
5
6
"github.com/stretchr/testify/require"
7
)
8
9
func TestMakeDynamicValuesCallback(t *testing.T) {
10
input := map[string][]string{
11
"a": {"1", "2"},
12
"b": {"3"},
13
"c": {},
14
"d": {"A", "B", "C"},
15
}
16
17
count := 0
18
MakeDynamicValuesCallback(input, true, func(data map[string]interface{}) bool {
19
count++
20
require.Len(t, data, 3, "could not get correct output length")
21
return false
22
})
23
require.Equal(t, 3, count, "could not get correct result count")
24
25
t.Run("all", func(t *testing.T) {
26
input := map[string][]string{
27
"a": {"1"},
28
"b": {"2"},
29
"c": {"3"},
30
}
31
32
count := 0
33
MakeDynamicValuesCallback(input, true, func(data map[string]interface{}) bool {
34
count++
35
require.Len(t, data, 3, "could not get correct output length")
36
return false
37
})
38
require.Equal(t, 1, count, "could not get correct result count")
39
})
40
41
t.Run("first", func(t *testing.T) {
42
input := map[string][]string{
43
"a": {"1", "2"},
44
"b": {"3"},
45
"c": {},
46
"d": {"A", "B", "C"},
47
}
48
49
count := 0
50
MakeDynamicValuesCallback(input, false, func(data map[string]interface{}) bool {
51
count++
52
require.Len(t, data, 3, "could not get correct output length")
53
return false
54
})
55
require.Equal(t, 1, count, "could not get correct result count")
56
})
57
}
58
59