Update API version of Go test. Also fix a couple things.
This commit is contained in:
parent
d114f39137
commit
57574df87e
|
@ -32,14 +32,14 @@ import (
|
|||
func ExampleOpenDefault() {
|
||||
var e error
|
||||
|
||||
e = fdb.APIVersion(400)
|
||||
e = fdb.APIVersion(630)
|
||||
if e != nil {
|
||||
fmt.Printf("Unable to set API version: %v\n", e)
|
||||
return
|
||||
}
|
||||
|
||||
// OpenDefault opens the database described by the platform-specific default
|
||||
// cluster file and the database name []byte("DB").
|
||||
// cluster file
|
||||
db, e := fdb.OpenDefault()
|
||||
if e != nil {
|
||||
fmt.Printf("Unable to open default database: %v\n", e)
|
||||
|
@ -47,16 +47,18 @@ func ExampleOpenDefault() {
|
|||
}
|
||||
|
||||
_ = db
|
||||
|
||||
// Output:
|
||||
}
|
||||
|
||||
func ExampleVersionstamp(t *testing.T) {
|
||||
fdb.MustAPIVersion(400)
|
||||
func TestVersionstamp(t *testing.T) {
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
setVs := func(t fdb.Transactor, key fdb.Key) (fdb.FutureKey, error) {
|
||||
fmt.Printf("setOne called with: %T\n", t)
|
||||
ret, e := t.Transact(func(tr fdb.Transaction) (interface{}, error) {
|
||||
tr.SetVersionstampedValue(key, []byte("blahblahbl"))
|
||||
tr.SetVersionstampedValue(key, []byte("blahblahbl\x00\x00\x00\x00"))
|
||||
return tr.GetVersionstamp(), nil
|
||||
})
|
||||
return ret.(fdb.FutureKey), e
|
||||
|
@ -76,16 +78,27 @@ func ExampleVersionstamp(t *testing.T) {
|
|||
var v []byte
|
||||
var fvs fdb.FutureKey
|
||||
var k fdb.Key
|
||||
var e error
|
||||
|
||||
fvs, _ = setVs(db, fdb.Key("foo"))
|
||||
v, _ = getOne(db, fdb.Key("foo"))
|
||||
t.Log(v)
|
||||
k, _ = fvs.Get()
|
||||
fvs, e = setVs(db, fdb.Key("foo"))
|
||||
if e != nil {
|
||||
t.Errorf("setOne failed %v", e)
|
||||
}
|
||||
v, e = getOne(db, fdb.Key("foo"))
|
||||
if e != nil {
|
||||
t.Errorf("getOne failed %v", e)
|
||||
}
|
||||
t.Logf("getOne returned %s", v)
|
||||
k, e = fvs.Get()
|
||||
if e != nil {
|
||||
t.Errorf("setOne wait failed %v", e)
|
||||
}
|
||||
t.Log(k)
|
||||
t.Logf("setOne returned %s", k)
|
||||
}
|
||||
|
||||
func ExampleTransactor() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
setOne := func(t fdb.Transactor, key fdb.Key, value []byte) error {
|
||||
|
@ -136,7 +149,7 @@ func ExampleTransactor() {
|
|||
}
|
||||
|
||||
func ExampleReadTransactor() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
getOne := func(rt fdb.ReadTransactor, key fdb.Key) ([]byte, error) {
|
||||
|
@ -189,7 +202,7 @@ func ExampleReadTransactor() {
|
|||
}
|
||||
|
||||
func ExamplePrefixRange() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
tr, e := db.CreateTransaction()
|
||||
|
@ -228,7 +241,7 @@ func ExamplePrefixRange() {
|
|||
}
|
||||
|
||||
func ExampleRangeIterator() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
tr, e := db.CreateTransaction()
|
||||
|
@ -278,6 +291,8 @@ func TestKeyToString(t *testing.T) {
|
|||
t.Errorf("got '%v', want '%v' at case %v", s, c.expect, i)
|
||||
}
|
||||
}
|
||||
|
||||
// Output:
|
||||
}
|
||||
|
||||
func ExamplePrintable() {
|
||||
|
|
Loading…
Reference in New Issue