()
| 26 | ) |
| 27 | |
| 28 | func getTestConn() *redis.Client { |
| 29 | log.SetOutput(os.Stderr) |
| 30 | f := func() { |
| 31 | conf.DataDir = "/tmp/icefiredb" |
| 32 | os.RemoveAll(conf.DataDir) |
| 33 | conf.DataDirReady = func(dir string) { |
| 34 | os.RemoveAll(filepath.Join(dir, "main.db")) |
| 35 | |
| 36 | ldsCfg = lediscfg.NewConfigDefault() |
| 37 | ldsCfg.DataDir = filepath.Join(dir, "main.db") |
| 38 | ldsCfg.Databases = 1 |
| 39 | ldsCfg.DBName = os.Getenv("DRIVER") |
| 40 | var err error |
| 41 | le, err = ledis.Open(ldsCfg) |
| 42 | if err != nil { |
| 43 | panic(err) |
| 44 | } |
| 45 | |
| 46 | ldb, err = le.Select(0) |
| 47 | if err != nil { |
| 48 | panic(err) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | conf.Snapshot = snapshot |
| 53 | conf.Restore = restore |
| 54 | fmt.Printf("start with Storage Engine: %s\n", os.Getenv("DRIVER")) |
| 55 | go uhaha.Main(conf) |
| 56 | |
| 57 | testRedisClient = redis.NewClient(&redis.Options{ |
| 58 | Addr: "127.0.0.1:11001", |
| 59 | }) |
| 60 | |
| 61 | log.Println("waiting for DB bootstrap") |
| 62 | // wait server starts |
| 63 | backoff.Retry(func() error { |
| 64 | _, err := testRedisClient.Set(context.Background(), "init", "1", 0).Result() |
| 65 | return err |
| 66 | }, backoff.NewConstantBackOff(1*time.Second)) |
| 67 | |
| 68 | // clean all data |
| 69 | testRedisClient.FlushAll(context.Background()) |
| 70 | } |
| 71 | testConnOnce.Do(f) |
| 72 | return testRedisClient |
| 73 | } |
no test coverage detected