2014-06-03 05:51:29 +04:00
|
|
|
package replication
|
2014-05-27 12:05:24 +04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBinLog(t *testing.T) {
|
|
|
|
cfg := new(BinLogConfig)
|
|
|
|
|
|
|
|
cfg.MaxFileNum = 1
|
|
|
|
cfg.MaxFileSize = 1024
|
|
|
|
cfg.Path = "/tmp/ledis_binlog"
|
2014-06-06 06:34:57 +04:00
|
|
|
cfg.Name = "ledis"
|
2014-05-27 12:05:24 +04:00
|
|
|
|
|
|
|
os.RemoveAll(cfg.Path)
|
|
|
|
|
|
|
|
b, err := NewBinLogWithConfig(cfg)
|
|
|
|
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(cfg.Path); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else if len(fs) != 2 {
|
|
|
|
t.Fatal(len(fs))
|
|
|
|
}
|
|
|
|
}
|