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 testConnOnce sync.Once
27 testRedisClient *redis.Client
28)
29
30func getTestConn() *redis.Client {
31 log.SetOutput(os.Stderr)
32 f := func() {
33 // Allow tests to redirect the OSS storage backend at an arbitrary
34 // S3-compatible endpoint. The default in driver/oss/db.go is
35 // "http://localhost:9000" (MinIO), but CI may run LocalStack or
36 // MinIO on a different port. confInit() — which parses the
37 // --oss-endpoint flag — is only invoked from main() and tests go
38 // straight to uhaha.Main(), so we have to apply the override here.
39 if endpoint := os.Getenv("OSS_TEST_ENDPOINT"); endpoint != "" {
40 oss.OssDefaultConfig.EndPointConnection = endpoint
41 }
42 if accessKey := os.Getenv("OSS_TEST_ACCESS_KEY"); accessKey != "" {
43 oss.OssDefaultConfig.AccessKey = accessKey
44 }
45 if secretKey := os.Getenv("OSS_TEST_SECRET_KEY"); secretKey != "" {
46 oss.OssDefaultConfig.Secretkey = secretKey
47 }
48 conf.DataDir = "/tmp/icefiredb"
49 os.RemoveAll(conf.DataDir)
50 conf.DataDirReady = func(dir string) {
51 os.RemoveAll(filepath.Join(dir, "main.db"))
52
53 ldsCfg = lediscfg.NewConfigDefault()
54 ldsCfg.DataDir = filepath.Join(dir, "main.db")
55 ldsCfg.Databases = 1
56 ldsCfg.DBName = os.Getenv("DRIVER")
57 var err error
58 le, err = ledis.Open(ldsCfg)
59 if err != nil {
60 panic(err)
61 }
62
63 ldb, err = le.Select(0)
64 if err != nil {
65 panic(err)
66 }
67 }
68
69 conf.Snapshot = snapshot
70 conf.Restore = restore
71 fmt.Printf("start with Storage Engine: %s\n", os.Getenv("DRIVER"))
72 go uhaha.Main(conf)
73
74 testRedisClient = redis.NewClient(&redis.Options{
75 Addr: "127.0.0.1:11001",
76 })

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