forked from AfterShip/email-verifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
74 lines (62 loc) · 1.71 KB
/
util_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
72
73
74
package emailverifier
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDomainToASCII(t *testing.T) {
domain := "testingΣ✪✯☭➳卐.org"
ret := domainToASCII(domain)
expected := "xn--testing-0if2960fjccubz8h9z13a.org"
assert.Equal(t, expected, ret)
}
func TestDomainToASCII_NormalDomain(t *testing.T) {
domain := "testing.org"
ret := domainToASCII(domain)
expected := "testing.org"
assert.Equal(t, expected, ret)
}
func TestCallJobFuncWithParams_NoOutput(t *testing.T) {
f := func(a string) { fmt.Println(a) }
ret := callJobFuncWithParams(f, []interface{}{"testing"})
assert.Nil(t, ret)
}
func TestCallJobFuncWithParams_WithOutput(t *testing.T) {
f := func(a int) int { return a * (1 + a) }
ret := callJobFuncWithParams(f, []interface{}{2})
assert.Equal(t, int64(6), ret[0].Int())
}
func TestCallJobFuncForgetParams(t *testing.T) {
f := func(a int) int { return a * (1 + a) }
ret := callJobFuncWithParams(f, nil)
assert.Nil(t, ret)
}
func TestCallJobFuncWithWrongFunc(t *testing.T) {
f := 3
ret := callJobFuncWithParams(f, nil)
assert.Nil(t, ret)
}
func TestSplitDomainNoSLD(t *testing.T) {
domain := "com"
sld, tld := splitDomain(domain)
assert.Equal(t, sld, "")
assert.Equal(t, tld, domain)
}
func TestSplitDomainOK(t *testing.T) {
domain := "aftership.com"
sld, tld := splitDomain(domain)
assert.Equal(t, sld, "aftership")
assert.Equal(t, tld, "com")
}
func TestSplitDomainNilString(t *testing.T) {
domain := ""
sld, tld := splitDomain(domain)
assert.Equal(t, sld, "")
assert.Equal(t, tld, "")
}
func TestSplitDomainSubDomain(t *testing.T) {
domain := "develop.aftership.com"
sld, tld := splitDomain(domain)
assert.Equal(t, sld, "aftership")
assert.Equal(t, tld, "com")
}