mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
30 lines
533 B
Go
30 lines
533 B
Go
package backend
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestBackendPut(t *testing.T) {
|
|
backend := New("test", 10*time.Second, 10000)
|
|
defer backend.Close()
|
|
defer os.Remove("test")
|
|
|
|
v := []byte("foo")
|
|
|
|
batchTx := backend.BatchTx()
|
|
batchTx.Lock()
|
|
|
|
batchTx.UnsafeCreateBucket([]byte("test"))
|
|
|
|
batchTx.UnsafePut([]byte("test"), []byte("foo"), v)
|
|
gv := batchTx.UnsafeRange([]byte("test"), v, nil, -1)
|
|
if !reflect.DeepEqual(gv[0], v) {
|
|
t.Errorf("v = %s, want %s", string(gv[0]), string(v))
|
|
}
|
|
|
|
batchTx.Unlock()
|
|
}
|