create cluster

This commit is contained in:
Yun
2023-08-27 23:39:58 +08:00
parent 60e0478a62
commit 3ccce0bba2
11 changed files with 571 additions and 121 deletions
+37 -11
View File
@@ -1,21 +1,47 @@
package timer_test
package timer
import (
"context"
"fmt"
"code.yun.ink/open/timer"
"testing"
"github.com/go-redis/redis/v8"
)
// 示例测试
func exampleDemo(ctx context.Context) bool {
fmt.Println("fff")
return false
// func exampleDemo(ctx context.Context) bool {
// fmt.Println("fff")
// return false
// }
// func ExampleB() {
// ctx := context.Background()
// timer.InitSingle(ctx)
// timer.AddToTimer(1, exampleDemo)
// // OutPut:
// }
func TestMain(m *testing.M) {
client := redis.NewClient(&redis.Options{
Addr: "127.0.0.1" + ":" + "6379",
Password: "", // no password set
DB: 0, // use default DB
})
if client == nil {
fmt.Println("redis init error")
return
}
Redis = client
}
func ExampleB() {
ctx := context.Background()
timer.InitSingle(ctx)
timer.AddToTimer(1, exampleDemo)
// OutPut:
func TestRedis(t *testing.T) {
fmt.Println("6666")
// t.Fail()
// t.Error("ffff")
// Redis.Set(context.Background(), "dddd", "dddd", 0)
// str, err := Redis.Get(context.Background(), "dddd").Result()
// fmt.Println("ssss", str, err)
// t.Log(str, err)
// t.Fail()
}