ledisdb/ledis/binlog_test.go

38 lines
603 B
Go
Raw Normal View History

package ledis
2014-05-27 12:05:24 +04:00
import (
"github.com/siddontang/ledisdb/config"
2014-05-27 12:05:24 +04:00
"io/ioutil"
"os"
"testing"
)
func TestBinLog(t *testing.T) {
cfg := new(config.Config)
2014-05-27 12:05:24 +04:00
cfg.BinLog.MaxFileNum = 1
cfg.BinLog.MaxFileSize = 1024
cfg.DataDir = "/tmp/ledis_binlog"
2014-05-27 12:05:24 +04:00
os.RemoveAll(cfg.DataDir)
2014-05-27 12:05:24 +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)
}
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))
}
}