()
| 26 | testConnOnce sync.Once |
| 27 | testRedisClient *redis.Client |
| 28 | ) |
| 29 | |
| 30 | func 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 | }) |
no test coverage detected