From 862cde393cca25fdf04b883aa331a88a3fec67a7 Mon Sep 17 00:00:00 2001 From: Vladimir Buzuev Date: Mon, 4 May 2020 11:01:38 -0700 Subject: cache_opts: address PR comments --- settings_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'settings_test.go') diff --git a/settings_test.go b/settings_test.go index 3a4ce0a..4e45567 100644 --- a/settings_test.go +++ b/settings_test.go @@ -48,3 +48,36 @@ func TestMmapSizes(t *testing.T) { t.Fatal("Sizes don't match") } } + +func TestEnableCaching(t *testing.T) { + err := EnableCaching(false) + checkFatal(t, err) + + err = EnableCaching(true) + checkFatal(t, err) +} + +func TestGetCachedMemory(t *testing.T) { + current, allowed, err := GetCachedMemory() + checkFatal(t, err) + + if current < 0 { + t.Fatal("current < 0") + } + + if allowed < 0 { + t.Fatal("allowed < 0") + } +} + +func TestSetCacheMaxSize(t *testing.T) { + err := SetCacheMaxSize(0) + checkFatal(t, err) + + err = SetCacheMaxSize(1024 * 1024) + checkFatal(t, err) + + // revert to default 256MB + err = SetCacheMaxSize(256 * 1024 * 1024) + checkFatal(t, err) +} \ No newline at end of file -- cgit v1.2.3