-
-
Notifications
You must be signed in to change notification settings - Fork 910
/
Copy pathparse_test.go
71 lines (64 loc) · 1.54 KB
/
parse_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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package core
import (
"fmt"
"github.com/flosch/pongo2/v6"
"runtime"
"testing"
)
func TestParseTarget(t *testing.T) {
fmt.Println("----> INPUT:", "http://example.com")
result := ParseTarget("http://exmaple.com")
fmt.Println(result)
if len(result) == 0 {
t.Errorf("Error RunMasscan")
}
// case 2
fmt.Println("----> INPUT:", "example.com")
result = ParseTarget("exmaple.com")
fmt.Println(result)
if len(result) == 0 {
t.Errorf("Error RunMasscan")
}
// case 2
fmt.Println("----> INPUT:", "http://exmaple.com/123?q=1")
result = ParseTarget("http://exmaple.com/123?q=1")
fmt.Println(result)
if len(result) == 0 {
t.Errorf("Error RunMasscan")
}
// case 2
fmt.Println("----> INPUT:", "1.2.3.4")
result = ParseTarget("1.2.3.4")
fmt.Println(result)
if len(result) == 0 {
t.Errorf("Error RunMasscan")
}
// case 2
fmt.Println("----> INPUT:", "1.2.3.4/24")
result = ParseTarget("1.2.3.4/24")
fmt.Println(result)
if len(result) == 0 {
t.Errorf("Error RunMasscan")
}
}
func TestRenderTemplate(t *testing.T) {
formatString := "Hello {{name}}! \n"
formatString += "--> Express: {{ 2 * cpu }} \n"
formatString += "--> Bool: {{ Skip }} \n"
target := map[string]any{
"name": "World",
"num": "2",
"cpu": runtime.NumCPU(),
"Skip": true,
}
fmt.Println(target)
if tpl, err := pongo2.FromString(formatString); err == nil {
// Now you can render the template with the given
// pongo2.Context how often you want to.
out, err := tpl.Execute(target)
if err != nil {
panic(err)
}
fmt.Println(out) // Output: Hello Florian!
}
}