1
1
package database
2
2
3
3
import (
4
- "github.com/hdt3213/godis/aof"
5
- "github.com/hdt3213/godis/config"
6
- "github.com/hdt3213/godis/lib/utils"
7
- "github.com/hdt3213/godis/redis/connection"
8
- "github.com/hdt3213/godis/redis/protocol/asserts"
9
4
"io/ioutil"
5
+ "os"
10
6
"path/filepath"
11
7
"runtime"
12
8
"testing"
13
9
"time"
10
+
11
+ "github.com/hdt3213/godis/aof"
12
+ "github.com/hdt3213/godis/config"
13
+ "github.com/hdt3213/godis/lib/utils"
14
+ "github.com/hdt3213/godis/redis/connection"
15
+ "github.com/hdt3213/godis/redis/protocol/asserts"
14
16
)
15
17
16
18
func TestLoadRDB (t * testing.T ) {
17
19
_ , b , _ , _ := runtime .Caller (0 )
18
20
projectRoot := filepath .Dir (filepath .Dir (b ))
21
+ os .Chdir (projectRoot )
19
22
config .Properties = & config.ServerProperties {
20
23
AppendOnly : false ,
21
- RDBFilename : filepath . Join ( projectRoot , "test.rdb" ) , // set working directory to project root
24
+ RDBFilename : "test.rdb" , // set working directory to project root
22
25
}
23
26
conn := connection .NewFakeConn ()
24
27
rdbDB := NewStandaloneServer ()
@@ -38,7 +41,7 @@ func TestLoadRDB(t *testing.T) {
38
41
// test no rdb file
39
42
config .Properties = & config.ServerProperties {
40
43
AppendOnly : false ,
41
- RDBFilename : filepath . Join ( projectRoot , "none" , "test .rdb"), // set working directory to project root
44
+ RDBFilename : "noexists .rdb",
42
45
}
43
46
rdbDB = NewStandaloneServer ()
44
47
result = rdbDB .Exec (conn , utils .ToCmdLine ("Get" , "str" ))
0 commit comments