This commit is contained in:
lzh 2025-06-18 16:45:01 +08:00
parent 82caad9679
commit 695dcf3c49

View File

@ -137,7 +137,30 @@ func TestSmsClient_SaveCode(t *testing.T) {
goRedis := NewRedisCacheAdapter(addr, redisPassword, db)
smsClient.Cache = goRedis
err = smsClient.SaveCode(context.Background(), codeKey, "123456", time.Minute*5, time.Minute)
err = smsClient.SaveCode(context.Background(), codeKey, "123456", time.Minute*5)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println("保存成功")
}
func TestSmsClient_SaveCodeWithFrequency(t *testing.T) {
config := &SmsConfig{
AccessKeyId: accessKeyId,
AccessKeySecret: accessKeySecret,
}
smsClient, err := NewSmsClient(config)
if err != nil {
fmt.Println(err.Error())
return
}
addr := fmt.Sprintf("%s:%s", redisHost, redisPort)
db, _ := strconv.Atoi(redisDb)
goRedis := NewRedisCacheAdapter(addr, redisPassword, db)
smsClient.Cache = goRedis
err = smsClient.SaveCodeWithFrequency(context.Background(), codeKey, "123456", time.Minute*5, time.Minute)
if err != nil {
fmt.Println(err.Error())
return