1package bbolt
2
3import (
4	"testing"
5)
6
7func TestTx_allocatePageStats(t *testing.T) {
8	f := newTestFreelist()
9	ids := []pgid{2, 3}
10	f.readIDs(ids)
11
12	tx := &Tx{
13		db: &DB{
14			freelist: f,
15			pageSize: defaultPageSize,
16		},
17		meta:  &meta{},
18		pages: make(map[pgid]*page),
19	}
20
21	prePageCnt := tx.Stats().PageCount
22	allocateCnt := f.free_count()
23
24	if _, err := tx.allocate(allocateCnt); err != nil {
25		t.Fatal(err)
26	}
27
28	if tx.Stats().PageCount != prePageCnt+allocateCnt {
29		t.Errorf("Allocated %d but got %d page in stats", allocateCnt, tx.Stats().PageCount)
30	}
31}
32