summary refs log tree commit diff stats
path: root/svc/cache_test.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-11 04:14:32 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-11 04:54:52 -0400
commit367e44f691dbd5647a7d6ae7bdbd7857b35d92a8 (patch)
treed6237e3bd3cd483801f04f19f41a41840845764e /svc/cache_test.go
parent7cc45ff9314bb3343760811318b8bc238e6d945a (diff)
downloadgetwtxt-367e44f691dbd5647a7d6ae7bdbd7857b35d92a8.tar.gz
eliminated confObj.LastCache and confObj.LastPush. Unneeded when using ticker for intervals.
Diffstat (limited to 'svc/cache_test.go')
-rw-r--r--svc/cache_test.go28
1 files changed, 10 insertions, 18 deletions
diff --git a/svc/cache_test.go b/svc/cache_test.go
index 28e5c0b..2177917 100644
--- a/svc/cache_test.go
+++ b/svc/cache_test.go
@@ -4,26 +4,9 @@ import (
 	"testing"
 )
 
-func Test_cacheUpdate(t *testing.T) {
-	initTestConf()
-	confObj.Mu.RLock()
-	prevtime := confObj.LastCache
-	confObj.Mu.RUnlock()
-
-	t.Run("Cache Time Check", func(t *testing.T) {
-		cacheUpdate()
-		confObj.Mu.RLock()
-		newtime := confObj.LastCache
-		confObj.Mu.RUnlock()
-
-		if !newtime.After(prevtime) || newtime == prevtime {
-			t.Errorf("Cache time did not update, check cacheUpdate() logic\n")
-		}
-	})
-}
-
 func Benchmark_cacheUpdate(b *testing.B) {
 	initTestConf()
+	mockRegistry()
 	b.ResetTimer()
 
 	for i := 0; i < b.N; i++ {
@@ -37,5 +20,14 @@ func Benchmark_pingAssets(b *testing.B) {
 
 	for i := 0; i < b.N; i++ {
 		pingAssets()
+
+		// We'll only have to reload the cache occasionally,
+		// so only start with an empty staticCache 25% of
+		// the time.
+		if float64(i) > (float64(b.N) * .75) {
+			b.StopTimer()
+			staticCache = &staticAssets{}
+			b.StartTimer()
+		}
 	}
 }