MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / getTestConn

Function getTestConn

conn_test.go:28–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26)
27
28func 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}

Callers 15

testListIndexFunction · 0.85
testListRangeFunction · 0.85
TestListFunction · 0.85
TestListMPushFunction · 0.85
TestPopFunction · 0.85
TestRPopLPushFunction · 0.85
TestTrimFunction · 0.85
TestListErrorParamsFunction · 0.85
TestDBSetFunction · 0.85
TestSetOperationFunction · 0.85
TestSKeyExistsFunction · 0.85

Calls 3

SetMethod · 0.80
OpenMethod · 0.45
DoMethod · 0.45

Tested by

no test coverage detected