1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-10 07:42:26 +08:00

Adaptation of new go-redis components (#546)

* [feature] Format the code and improve Mini Program authorization to obtain openid(miniprogram/auth/auth.go Code2Session)

* [feature] CheckEncryptedData (https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.checkEncryptedData.html)

* upgrade json error

* upgrade json error

* [feature] Wallet Transfer returns the pointer object

* feat:Adaptation of new go-redis components

* improve code

* feat:upgrade golangci-lint-action version

* fix

* test ci

* fix

* test ci

* fix

* test

* improve code

* feat:GetPhoneNumber return ptr

Co-authored-by: houseme <houseme@outlook.com>
This commit is contained in:
houseme
2022-04-14 10:07:58 +08:00
committed by GitHub
parent 1b5c5fba67
commit 8e81a416c5
30 changed files with 232 additions and 153 deletions

29
cache/redis_test.go vendored
View File

@@ -1,33 +1,40 @@
package cache
import (
"context"
"testing"
"time"
)
func TestRedis(t *testing.T) {
opts := &RedisOpts{
Host: "127.0.0.1:6379",
}
redis := NewRedis(opts)
var (
timeoutDuration = time.Second
ctx = context.Background()
opts = &RedisOpts{
Host: "127.0.0.1:6379",
}
redis = NewRedis(ctx, opts)
err error
val = "silenceper"
key = "username"
)
redis.SetConn(redis.conn)
var err error
timeoutDuration := 1 * time.Second
redis.SetRedisCtx(ctx)
if err = redis.Set("username", "silenceper", timeoutDuration); err != nil {
if err = redis.Set(key, val, timeoutDuration); err != nil {
t.Error("set Error", err)
}
if !redis.IsExist("username") {
if !redis.IsExist(key) {
t.Error("IsExist Error")
}
name := redis.Get("username").(string)
if name != "silenceper" {
name := redis.Get(key).(string)
if name != val {
t.Error("get Error")
}
if err = redis.Delete("username"); err != nil {
if err = redis.Delete(key); err != nil {
t.Errorf("delete Error , err=%v", err)
}
}