ledisdb/replication/relaylog_test.go

41 lines
619 B
Go
Raw Normal View History

2014-06-03 05:51:29 +04:00
package replication
import (
2014-06-03 10:08:57 +04:00
"os"
2014-06-03 05:51:29 +04:00
"testing"
)
func TestRelayLog(t *testing.T) {
2014-06-03 10:08:57 +04:00
cfg := new(RelayLogConfig)
cfg.MaxFileSize = 1024
cfg.SpaceLimit = 1024
cfg.Path = "/tmp/ledis_relaylog"
os.RemoveAll(cfg.Path)
b, err := NewRelayLogWithConfig(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, 1)); err == nil {
t.Fatal("must not nil")
} else if err != ErrOverSpaceLimit {
t.Fatal(err)
}
if err := b.Purge(1); err != nil {
t.Fatal(err)
}
if err := b.Log(make([]byte, 1)); err != nil {
t.Fatal(err)
}
2014-06-03 05:51:29 +04:00
}