Commit aa5e9280 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9033940f
...@@ -101,7 +101,7 @@ type revCacheEntry struct { ...@@ -101,7 +101,7 @@ type revCacheEntry struct {
} }
func NewCache(loader storLoader) *Cache { func NewCache(loader storLoader) *Cache {
return &Cache{loader: loader} return &Cache{loader: loader, entryMap: make(map[zodb.Oid]*oidCacheEntry)}
} }
// newReveEntry creates new revCacheEntry with .before and inserts it into .revv @i // newReveEntry creates new revCacheEntry with .before and inserts it into .revv @i
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package client package client
import ( import (
"reflect"
"sort" "sort"
"testing" "testing"
...@@ -116,15 +117,26 @@ func TestCache(t *testing.T) { ...@@ -116,15 +117,26 @@ func TestCache(t *testing.T) {
// rcePrev + rce // rcePrev + rce
// rcePrev + (rce + rceNext) // rcePrev + (rce + rceNext)
ok1 := func(v bool) { t.Helper(); if !v { t.Fatal("!ok") } }
eq := reflect.DeepEqual
c := NewCache(tstor) c := NewCache(tstor)
c.Load(1, <2) -> nil, 0, &zodb.ErrXidMissing xid1 := zodb.Xid{Oid: 1, XTid: zodb.XTid{Tid: 2, TidBefore: true}}
oce1 := c.entryMap[1] data, serial, err := c.Load(xid1) // -> nil, 0, &zodb.ErrXidMissing{1,<2}
len(oce1.revv) == 1 ok1(data == nil)
rce1_2 := oce1.revv[0] ok1(serial == 0)
rce1_2.before == 2 ok1(eq(err, &zodb.ErrXidMissing{xid1}))
rce1_2.serial == 0
rce1_2.err == zodb.ErrXidMissing
c.Load(1, <3) -> nil, 0, zodb.ErrXidMissing oce1 := c.entryMap[1]
ok1(len(oce1.revv) == 1)
rce1_b2 := oce1.revv[0]
ok1(rce1_b2.before == 2)
ok1(rce1_b2.serial == 0)
ok1(eq(rce1_b2.err, zodb.ErrXidMissing{xid1})) // XXX must be 1, ?0
xid1.Tid = 3
c.Load(xid1) // -> nil, 0, zodb.ErrXidMissing{1,<3}
ok1(len(oce1.revv) == 1)
ok1(oce1.revv[0] == rce1_b2)
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment