aboutsummaryrefslogtreecommitdiff
path: root/tests/dedo.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dedo.go')
-rw-r--r--tests/dedo.go46
1 files changed, 27 insertions, 19 deletions
diff --git a/tests/dedo.go b/tests/dedo.go
index d479b4c..9c541b7 100644
--- a/tests/dedo.go
+++ b/tests/dedo.go
@@ -31,6 +31,14 @@ import (
+// pageInfoT represents human readable information about a page.
+type pageInfoT struct{
+ id int
+ type_ string
+ count int
+ overflowCount int
+}
+
/// Tx.copyFile() copies the entire database to file at the given path. A
/// reader transaction is maintained during the copy so it is safe to continue
/// using the database while a copy is in progress.
@@ -51,7 +59,7 @@ func (tx *Tx) copyFile(path string, mode os.FileMode) error {
/// Tx.Page() returns page information for a given page number. This is only
/// safe for concurrent use when used by a writable transaction.
-func (tx *Tx) pageInfo(id int) (*PageInfo, error) {
+func (tx *Tx) pageInfo(id int) (*pageInfoT, error) {
if tx.db == nil {
return nil, ErrTxClosed
} else if pgid(id) >= tx.meta.pgid {
@@ -60,17 +68,17 @@ func (tx *Tx) pageInfo(id int) (*PageInfo, error) {
// Build the page info.
p := tx.db.page(pgid(id))
- info := &PageInfo{
- ID: id,
- Count: int(p.count),
- OverflowCount: int(p.overflow),
+ info := &pageInfoT{
+ id: id,
+ count: int(p.count),
+ overflowCount: int(p.overflow),
}
// Determine the type (of if it's free).
if tx.db.freelist.freed(pgid(id)) {
- info.Type = "free"
+ info.type_ = "free"
} else {
- info.Type = p.typ()
+ info.type_ = p.typ()
}
return info, nil
@@ -3582,43 +3590,43 @@ func TestDB_Consistency(t *testing.T) {
p, _ := tx.pageInfo(0)
if p == nil {
t.Fatal("expected page")
- } else if p.Type != "meta" {
- t.Fatalf("unexpected page type: %s", p.Type)
+ } else if p.type_ != "meta" {
+ t.Fatalf("unexpected page type: %s", p.type_)
}
p, _ = tx.pageInfo(1)
if p == nil {
t.Fatal("expected page")
- } else if p.Type != "meta" {
- t.Fatalf("unexpected page type: %s", p.Type)
+ } else if p.type_ != "meta" {
+ t.Fatalf("unexpected page type: %s", p.type_)
}
p, _ = tx.pageInfo(2)
if p == nil {
t.Fatal("expected page")
- } else if p.Type != "free" {
- t.Fatalf("unexpected page type: %s", p.Type)
+ } else if p.type_ != "free" {
+ t.Fatalf("unexpected page type: %s", p.type_)
}
p, _ = tx.pageInfo(3)
if p == nil {
t.Fatal("expected page")
- } else if p.Type != "free" {
- t.Fatalf("unexpected page type: %s", p.Type)
+ } else if p.type_ != "free" {
+ t.Fatalf("unexpected page type: %s", p.type_)
}
p, _ = tx.pageInfo(4)
if p == nil {
t.Fatal("expected page")
- } else if p.Type != "leaf" {
- t.Fatalf("unexpected page type: %s", p.Type)
+ } else if p.type_ != "leaf" {
+ t.Fatalf("unexpected page type: %s", p.type_)
}
p, _ = tx.pageInfo(5)
if p == nil {
t.Fatal("expected page")
- } else if p.Type != "freelist" {
- t.Fatalf("unexpected page type: %s", p.Type)
+ } else if p.type_ != "freelist" {
+ t.Fatalf("unexpected page type: %s", p.type_)
}
p, _ = tx.pageInfo(6)