MCPcopy
hub / github.com/etcd-io/bbolt / TestFreeList_reload

Function TestFreeList_reload

internal/freelist/freelist_test.go:255–274  ·  internal/freelist/freelist_test.go::TestFreeList_reload
(t *testing.T)

Source from the content-addressed store, hash-verified

253}
254
255func TestFreeList_reload(t *testing.T) {
256 buf := make([]byte, 4096)
257 f := newTestFreelist()
258 f.Init(common.Pgids{5, 6, 8})
259
260 p := common.LoadPage(buf)
261 f.Write(p)
262
263 f2 := newTestFreelist()
264 f2.Read(p)
265 require.Equal(t, common.Pgids{5, 6, 8}, f2.freePageIds())
266
267 f2.Free(common.Txid(5), common.NewPage(10, common.LeafPageFlag, 0, 2))
268
269 // reload shouldn't affect the pending list
270 f2.Reload(p)
271
272 require.Equal(t, common.Pgids{5, 6, 8}, f2.freePageIds())
273 require.Equal(t, []common.Pgid{10, 11, 12}, f2.pendingPageIds()[5].ids)
274}
275
276// Ensure that the txIDx swap, less and len are properly implemented
277func TestTxidSorting(t *testing.T) {

Callers

nothing calls this directly

Calls 11

LoadPageFunction · 0.92
TxidTypeAlias · 0.92
NewPageFunction · 0.92
newTestFreelistFunction · 0.85
InitMethod · 0.65
WriteMethod · 0.65
ReadMethod · 0.65
freePageIdsMethod · 0.65
FreeMethod · 0.65
ReloadMethod · 0.65
pendingPageIdsMethod · 0.65

Tested by

no test coverage detected