test storing frame cache size

This commit is contained in:
Michael Baird 2017-03-20 11:19:02 -05:00 committed by Travis
parent 8e2592e706
commit 9a1a631dd4
2 changed files with 22 additions and 1 deletions

View file

@ -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
)

View file

@ -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)
}
}