2014-06-07 12:56:22 +04:00
|
|
|
package ledis
|
2014-05-27 12:05:24 +04:00
|
|
|
|
|
|
|
import (
|
2014-08-07 12:49:48 +04:00
|
|
|
"github.com/siddontang/ledisdb/config"
|
2014-05-27 12:05:24 +04:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBinLog(t *testing.T) {
|
2014-08-07 12:49:48 +04:00
|
|
|
cfg := new(config.Config)
|
2014-05-27 12:05:24 +04:00
|
|
|
|
2014-08-07 12:49:48 +04:00
|
|
|
cfg.BinLog.MaxFileNum = 1
|
|
|
|
cfg.BinLog.MaxFileSize = 1024
|
|
|
|
cfg.DataDir = "/tmp/ledis_binlog"
|
2014-05-27 12:05:24 +04:00
|
|
|
|
2014-08-07 12:49:48 +04:00
|
|
|
os.RemoveAll(cfg.DataDir)
|
2014-05-27 12:05:24 +04:00
|
|
|
|
2014-07-04 11:45:23 +04:00
|
|
|
b, err := NewBinLog(cfg)
|
2014-05-27 12:05:24 +04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := b.Log(make([]byte, 1024)); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := b.Log(make([]byte, 1024)); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2014-08-07 12:49:48 +04:00
|
|
|
if fs, err := ioutil.ReadDir(b.LogPath()); err != nil {
|
2014-05-27 12:05:24 +04:00
|
|
|
t.Fatal(err)
|
|
|
|
} else if len(fs) != 2 {
|
|
|
|
t.Fatal(len(fs))
|
|
|
|
}
|
|
|
|
}
|