mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 16:55:23 +00:00
* use parsed options while signing * update project layout to v3 * fix .gitignore * remove example template * misc updates * bump tlsx version * hide template sig warning with env * js: retain value while using log * fix nil pointer derefernce * misc doc update --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package operators
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMakeDynamicValuesCallback(t *testing.T) {
|
|
input := map[string][]string{
|
|
"a": {"1", "2"},
|
|
"b": {"3"},
|
|
"c": {},
|
|
"d": {"A", "B", "C"},
|
|
}
|
|
|
|
count := 0
|
|
MakeDynamicValuesCallback(input, true, func(data map[string]interface{}) bool {
|
|
count++
|
|
require.Len(t, data, 3, "could not get correct output length")
|
|
return false
|
|
})
|
|
require.Equal(t, 3, count, "could not get correct result count")
|
|
|
|
t.Run("all", func(t *testing.T) {
|
|
input := map[string][]string{
|
|
"a": {"1"},
|
|
"b": {"2"},
|
|
"c": {"3"},
|
|
}
|
|
|
|
count := 0
|
|
MakeDynamicValuesCallback(input, true, func(data map[string]interface{}) bool {
|
|
count++
|
|
require.Len(t, data, 3, "could not get correct output length")
|
|
return false
|
|
})
|
|
require.Equal(t, 1, count, "could not get correct result count")
|
|
})
|
|
|
|
t.Run("first", func(t *testing.T) {
|
|
input := map[string][]string{
|
|
"a": {"1", "2"},
|
|
"b": {"3"},
|
|
"c": {},
|
|
"d": {"A", "B", "C"},
|
|
}
|
|
|
|
count := 0
|
|
MakeDynamicValuesCallback(input, false, func(data map[string]interface{}) bool {
|
|
count++
|
|
require.Len(t, data, 3, "could not get correct output length")
|
|
return false
|
|
})
|
|
require.Equal(t, 1, count, "could not get correct result count")
|
|
})
|
|
}
|