forked from linexjlin/ss-web-manager
/
db_test.go
77 lines (65 loc) · 1.32 KB
/
db_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
75
76
77
package main
import "testing"
func dbSetup() {
RedisSetup("./redisDB/redis.sock")
}
func TestGetUserId(t *testing.T) {
dbSetup()
id, err := getUserId("line")
checkError(err)
t.Log("userId:", id)
}
func TestGetUserPass(t *testing.T) {
dbSetup()
pass, err := getUserPass("101")
checkError(err)
t.Log("userpass:", pass)
}
func TestCheckPassword(t *testing.T) {
dbSetup()
pass := checkPassword("line", "123")
if !pass {
t.Fatal("checkPassword failed")
}
pass = checkPassword("line", "ddd")
if pass {
t.Fatal("chekPassword failed")
}
}
/*
func TestGetUserInfo(t *testing.T) {
dbSetup()
ui, err := getUserInfo("101")
checkError(err)
t.Log("expired", ui.pUsed)
}*/
func TestGetServerIds(t *testing.T) {
dbSetup()
us, err := getServerIds()
checkError(err)
t.Log(us)
}
func TestUserServerInfo(t *testing.T) {
dbSetup()
ufs, err := getUserServerInfo("101")
checkError(err)
t.Log(ufs)
}
func TestGetTrafficDetail(t *testing.T) {
dbSetup()
data, err := getUserTrafficDetail("101")
checkError(err)
t.Log(data)
}
func TestAddServer(t *testing.T) {
dbSetup()
err := addServer("123.34.3.4", "LA98", "Los Angel", "1000", "aes-256-cfb")
checkError(err)
t.Log("OOOOKKKK")
}
func TestAddUser(t *testing.T) {
dbSetup()
err := addUser("line2", "sdasfasfd", "admin2@linkown.com")
checkError(err)
t.Log("OOOOKKKK")
}