-
Notifications
You must be signed in to change notification settings - Fork 0
/
link_test.go
52 lines (37 loc) · 994 Bytes
/
link_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
package httpflow
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_NewLinks(t *testing.T) {
ll := map[LinkKey]string{LinkActivation: "link"}
l := NewLinks(ll)
assert.Equal(t, ll, l.ll)
}
func Test_LinksPrep(t *testing.T) {
l := Links{}
assert.Zero(t, l.Prep(LinkActivation))
ll := map[LinkKey]string{LinkActivation: "activ?token=%s"}
l.ll = ll
ls := l.Prep(LinkRecovery, "123")
assert.Zero(t, ls)
ls = l.Prep(LinkActivation, "123", "123")
assert.NotEqual(t, "activ?token=123", ls)
ls = l.Prep(LinkActivation, "123")
assert.Equal(t, "activ?token=123", ls)
}
func Test_LinksExist(t *testing.T) {
l := Links{}
assert.False(t, l.Exist(LinkActivation))
ll := map[LinkKey]string{
LinkActivation: "activ?token=%s",
LinkVerification: "",
}
l.ll = ll
res := l.Exist(LinkActivation, LinkRecovery)
assert.False(t, res)
res = l.Exist(LinkActivation, LinkVerification)
assert.False(t, res)
res = l.Exist(LinkActivation)
assert.True(t, res)
}