storage: kill TODO in TestRange

This commit is contained in:
Yicheng Qin 2015-06-17 15:58:28 -07:00
parent 05228729a3
commit 9ad5e1e64f

View File

@ -4,7 +4,10 @@ import (
"bytes" "bytes"
"crypto/rand" "crypto/rand"
"os" "os"
"reflect"
"testing" "testing"
"github.com/coreos/etcd/storage/storagepb"
) )
func TestRange(t *testing.T) { func TestRange(t *testing.T) {
@ -14,30 +17,34 @@ func TestRange(t *testing.T) {
s.Put([]byte("foo"), []byte("bar")) s.Put([]byte("foo"), []byte("bar"))
s.Put([]byte("foo1"), []byte("bar1")) s.Put([]byte("foo1"), []byte("bar1"))
s.Put([]byte("foo2"), []byte("bar2")) s.Put([]byte("foo2"), []byte("bar2"))
kvs := []storagepb.KeyValue{
{Key: []byte("foo"), Value: []byte("bar")},
{Key: []byte("foo1"), Value: []byte("bar1")},
{Key: []byte("foo2"), Value: []byte("bar2")},
}
tests := []struct { tests := []struct {
key, end []byte key, end []byte
rev int64 rev int64
wrev int64 wrev int64
// TODO: change this to the actual kv wkvs []storagepb.KeyValue
wN int64
}{ }{
{ {
[]byte("foo"), []byte("foo3"), 0, []byte("foo"), []byte("foo3"), 0,
3, 3, 3, kvs,
}, },
{ {
[]byte("foo"), []byte("foo1"), 0, []byte("foo"), []byte("foo1"), 0,
3, 1, 3, kvs[:1],
}, },
{ {
[]byte("foo"), []byte("foo3"), 1, []byte("foo"), []byte("foo3"), 1,
1, 1, 1, kvs[:1],
}, },
{ {
[]byte("foo"), []byte("foo3"), 2, []byte("foo"), []byte("foo3"), 2,
2, 2, 2, kvs[:2],
}, },
} }
@ -46,12 +53,12 @@ func TestRange(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if len(kvs) != int(tt.wN) {
t.Errorf("#%d: len(kvs) = %d, want %d", i, len(kvs), tt.wN)
}
if rev != tt.wrev { if rev != tt.wrev {
t.Errorf("#%d: rev = %d, want %d", i, tt.rev, tt.wrev) t.Errorf("#%d: rev = %d, want %d", i, tt.rev, tt.wrev)
} }
if !reflect.DeepEqual(kvs, tt.wkvs) {
t.Errorf("#%d: kvs = %+v, want %+v", i, kvs, tt.wkvs)
}
} }
} }