mirror of https://github.com/ledisdb/ledisdb.git
41 lines
619 B
Go
41 lines
619 B
Go
package replication
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestRelayLog(t *testing.T) {
|
|
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)
|
|
}
|
|
|
|
}
|