ledisdb/ledis/event_test.go

35 lines
476 B
Go
Raw Normal View History

2014-09-17 13:54:04 +04:00
package ledis
import (
"reflect"
"testing"
)
func TestEvent(t *testing.T) {
k1 := []byte("k1")
v1 := []byte("v1")
k2 := []byte("k2")
k3 := []byte("k3")
v3 := []byte("v3")
b := new(eventBatch)
b.Put(k1, v1)
b.Delete(k2)
b.Put(k3, v3)
buf := b.Bytes()
ev2 := []event{
event{k1, v1},
event{k2, nil},
event{k3, v3},
}
if ev, err := decodeEventBatch(buf); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(ev, ev2) {
t.Fatal("not equal")
}
}