diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-06-05 15:36:23 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-06-05 15:36:23 -0400 |
commit | fd43c61bd128ad77b22db0537a9a4eb58490b0b5 (patch) | |
tree | 4c5fa7b33fadbf7c3e14e69b7d68ce280bc3810a /svc/cache_test.go | |
parent | 4658fe82be3e9d95e93fa5c7c7ca64a15cf2f1a1 (diff) | |
download | getwtxt-fd43c61bd128ad77b22db0537a9a4eb58490b0b5.tar.gz |
moved bulk of code to its own package to clean up source tree
Diffstat (limited to 'svc/cache_test.go')
-rw-r--r-- | svc/cache_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/svc/cache_test.go b/svc/cache_test.go new file mode 100644 index 0000000..d3dba29 --- /dev/null +++ b/svc/cache_test.go @@ -0,0 +1,32 @@ +package svc // import github.com/getwtxt/getwtxt/svc + +import ( + "testing" +) + +func Test_refreshCache(t *testing.T) { + initTestConf() + confObj.Mu.RLock() + prevtime := confObj.LastCache + confObj.Mu.RUnlock() + + t.Run("Cache Time Check", func(t *testing.T) { + refreshCache() + confObj.Mu.RLock() + newtime := confObj.LastCache + confObj.Mu.RUnlock() + + if !newtime.After(prevtime) || newtime == prevtime { + t.Errorf("Cache time did not update, check refreshCache() logic\n") + } + }) +} + +func Benchmark_refreshCache(b *testing.B) { + initTestConf() + b.ResetTimer() + + for i := 0; i < b.N; i++ { + refreshCache() + } +} |