Commit cb2ce72c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent abed4adb
...@@ -21,6 +21,9 @@ package neo ...@@ -21,6 +21,9 @@ package neo
import ( import (
"context" "context"
"testing" "testing"
"../zodb"
"../zodb/storage/fs1"
) )
// basic interaction between Client -- Storage // basic interaction between Client -- Storage
...@@ -30,7 +33,13 @@ func TestClientStorage(t *testing.T) { ...@@ -30,7 +33,13 @@ func TestClientStorage(t *testing.T) {
Sctx, Scancel := context.WithCancel(context.Background()) Sctx, Scancel := context.WithCancel(context.Background())
S := NewStorage(nil) // TODO zodb.storage.mem // TODO +readonly ?
zstor, err := fs1.Open(context.Background(), "../zodb/storage/fs1/testdata/1.fs")
if err != nil {
t.Fatalf("zstor: %v", err) // XXX err ctx ?
}
S := NewStorage(zstor)
wg.Gox(func() { wg.Gox(func() {
S.ServeLink(Sctx, Snl) S.ServeLink(Sctx, Snl)
// XXX + test error return // XXX + test error return
...@@ -41,9 +50,51 @@ func TestClientStorage(t *testing.T) { ...@@ -41,9 +50,51 @@ func TestClientStorage(t *testing.T) {
t.Fatalf("creating/identifying client: %v", err) t.Fatalf("creating/identifying client: %v", err)
} }
// verify LastTid
lastTidOk, err := zstor.LastTid()
if err != nil {
t.Fatalf("zstor: lastTid: %v", err)
}
lastTid, err := C.LastTid() lastTid, err := C.LastTid()
if !(lastTid == 111 && err == nil) { // XXX 111 if !(lastTid == lastTidOk && err == nil) {
t.Fatalf("C.LastTid -> %v, %v ; want %v, nil", lastTid, err, 111, err) t.Fatalf("C.LastTid -> %v, %v ; want %v, nil", lastTid, err, lastTidOk)
}
// verify Load for all {<,=}serial:oid
ziter := zstor.Iterate(zodb.Tid(0), zodb.TidMax)
for {
txni, dataIter, err := ziter.NextTxn()
if err == io.EOF {
break
}
if err != nil {
t.Fatalf("ziter.NextTxn: %v", err)
}
txni.Tid
for {
datai, err := dataIter.NextData()
if err == io.EOF {
break
}
if err != nil {
t.Fatalf("ziter.NextData: %v", err)
}
datai.Oid
datai.Tid
.Data
.DataTid
// XXX .Data = nil means deleted
zodb.Xid{zodb.XTid{datai.Tid, false}, datai.Oid} // =tid:oid
// TODO check Load
}
} }
// shutdown storage // shutdown storage
......
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
//
// XXX partly based on code from ZODB ?
// Package mem implements in-memory ZODB storage
package mem
// XXX not yet really needed
/*
import (
"../../../zodb"
)
// Storage is a ZODB storage which stores data in RAM.
type Storage struct {
}
var _ zodb.IStorage = (*Storage)(nil)
*/
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package wks package wks
import ( import (
_ "../../zodb/storage/mem"
_ "../../zodb/storage/fs1" _ "../../zodb/storage/fs1"
_ "../../neo" // XXX split into neo/client ? _ "../../neo" // XXX split into neo/client ?
) )
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