(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestTx_allocatePageStats(t *testing.T) { |
| 11 | for n, f := range map[string]freelist.Interface{"hashmap": freelist.NewHashMapFreelist(), "array": freelist.NewArrayFreelist()} { |
| 12 | t.Run(n, func(t *testing.T) { |
| 13 | ids := []common.Pgid{2, 3} |
| 14 | f.Init(ids) |
| 15 | |
| 16 | tx := &Tx{ |
| 17 | db: &DB{ |
| 18 | freelist: f, |
| 19 | pageSize: common.DefaultPageSize, |
| 20 | }, |
| 21 | meta: &common.Meta{}, |
| 22 | pages: make(map[common.Pgid]*common.Page), |
| 23 | } |
| 24 | |
| 25 | txStats := tx.Stats() |
| 26 | prePageCnt := txStats.GetPageCount() |
| 27 | allocateCnt := f.FreeCount() |
| 28 | |
| 29 | if _, err := tx.allocate(allocateCnt); err != nil { |
| 30 | t.Fatal(err) |
| 31 | } |
| 32 | |
| 33 | txStats = tx.Stats() |
| 34 | if txStats.GetPageCount() != prePageCnt+int64(allocateCnt) { |
| 35 | t.Errorf("Allocated %d but got %d page in stats", allocateCnt, txStats.GetPageCount()) |
| 36 | } |
| 37 | }) |
| 38 | } |
| 39 | } |
nothing calls this directly
no test coverage detected