user_credential_test.go
741 字节
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
package userAuth
import (
"strings"
"testing"
)
func TestRedisUserCredential(t *testing.T) {
initRedis()
key := "18860183050"
userAuth := NewRedisUserCredential(key)
saveCredential := "123456789"
var credential string
err := userAuth.AddAuth(saveCredential)
if err != nil {
t.Fatal(err)
}
credential, err = userAuth.GetAuth()
if err != nil {
t.Fatal("get auth", err)
}
if !userAuth.Exist() {
t.Fatal("except:true")
}
if !strings.EqualFold(credential, saveCredential) {
t.Fatal("check credential:", err)
}
if err = userAuth.RemoveAuth(); err != nil {
t.Fatal("remove:", err)
}
if v := userAuth.field(); v != "18860183050" {
t.Fatal("except:18860183050 get:", v)
}
if userAuth.Exist() {
t.Fatal(key)
}
}