-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tx: fix the number of pages is not incorrectly counted
- Loading branch information
zhesi.huang
committed
Nov 12, 2017
1 parent
3c6cbfb
commit 22635d7
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package bolt | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestTx_allocatePageStats(t *testing.T) { | ||
f := newFreelist() | ||
f.ids = []pgid{2, 3} | ||
|
||
tx := &Tx{ | ||
db: &DB{ | ||
freelist: f, | ||
pageSize: defaultPageSize, | ||
}, | ||
meta: &meta{}, | ||
pages: make(map[pgid]*page), | ||
} | ||
|
||
prePageCnt := tx.Stats().PageCount | ||
allocateCnt := f.free_count() | ||
|
||
if _, err := tx.allocate(allocateCnt); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if tx.Stats().PageCount != prePageCnt+allocateCnt { | ||
t.Errorf("Allocated %d but got %d page in stats", allocateCnt, tx.Stats().PageCount) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters