mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 21:02:25 +08:00
* [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>
41 lines
690 B
Go
41 lines
690 B
Go
package cache
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestRedis(t *testing.T) {
|
|
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)
|
|
redis.SetRedisCtx(ctx)
|
|
|
|
if err = redis.Set(key, val, timeoutDuration); err != nil {
|
|
t.Error("set Error", err)
|
|
}
|
|
|
|
if !redis.IsExist(key) {
|
|
t.Error("IsExist Error")
|
|
}
|
|
|
|
name := redis.Get(key).(string)
|
|
if name != val {
|
|
t.Error("get Error")
|
|
}
|
|
|
|
if err = redis.Delete(key); err != nil {
|
|
t.Errorf("delete Error , err=%v", err)
|
|
}
|
|
}
|