From 9a1a631dd4dac53beaf07de6ec5c22608000fc30 Mon Sep 17 00:00:00 2001 From: Michael Baird Date: Mon, 20 Mar 2017 11:19:02 -0500 Subject: [PATCH] test storing frame cache size --- fragment.go | 2 +- frame_test.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/fragment.go b/fragment.go index 4f6362193..e83f76ed2 100644 --- a/fragment.go +++ b/fragment.go @@ -44,7 +44,7 @@ const ( // HashBlockSize is the number of bitmaps in a merkle hash block. HashBlockSize = 100 - // Percentage of the ThresholdLength size to resort the cache at + // ThresholdBufferPct is the percentage of the ThresholdLength size to resort the cache at ThresholdBufferPct = 0.9 ) diff --git a/frame_test.go b/frame_test.go index 5b659f826..16b935937 100644 --- a/frame_test.go +++ b/frame_test.go @@ -126,3 +126,24 @@ func (f *Frame) MustSetBit(view string, bitmapID, profileID uint64, t *time.Time } return changed } + +// Ensure frame can set its cache +func TestFrame_SetCacheSize(t *testing.T) { + f := MustOpenFrame() + defer f.Close() + cacheSize := 100 + + // Set & retrieve frame cache size. + if err := f.SetRankedCacheSize(cacheSize); err != nil { + t.Fatal(err) + } else if q := f.RankedCacheSize(); q != cacheSize { + t.Fatalf("unexpected frame cache size: %d", q) + } + + // Reload frame and verify that it is persisted. + if err := f.Reopen(); err != nil { + t.Fatal(err) + } else if q := f.RankedCacheSize(); q != cacheSize { + t.Fatalf("unexpected frame cache size (reopen): %d", q) + } +}