aboutsummaryrefslogtreecommitdiffstats
path: root/cache/repo_cache_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2023-01-14 14:21:01 +0100
committerGitHub <noreply@github.com>2023-01-14 14:21:01 +0100
commit98eb1c111efb22ddb02ab71779f1862abab4baa5 (patch)
treebb4d8bc2c1fd5614d274dab272e7dae03da5496b /cache/repo_cache_test.go
parent9c50a359704f4edd2f33df6d256e032feae3a576 (diff)
parent5bf274e64a3486bba21edd9bf455089839219f25 (diff)
downloadgit-bug-98eb1c111efb22ddb02ab71779f1862abab4baa5.tar.gz
Merge pull request #933 from zinderic/feat-cleanup-subcommand
add cleanup sub-command that remove local bugs and identities
Diffstat (limited to 'cache/repo_cache_test.go')
-rw-r--r--cache/repo_cache_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/cache/repo_cache_test.go b/cache/repo_cache_test.go
index 07a3fee8..3c11220d 100644
--- a/cache/repo_cache_test.go
+++ b/cache/repo_cache_test.go
@@ -135,6 +135,39 @@ func TestCache(t *testing.T) {
_, err = cache.Bugs().ResolvePrefix(bug1.Id().String()[:10])
require.NoError(t, err)
+ require.Len(t, cache.bugs.cached, 1)
+ require.Len(t, cache.bugs.excerpts, 2)
+ require.Len(t, cache.identities.cached, 1)
+ require.Len(t, cache.identities.excerpts, 2)
+ require.Equal(t, uint64(2), indexCount(t, identity.Namespace))
+ require.Equal(t, uint64(2), indexCount(t, bug.Namespace))
+
+ // Remove + RemoveAll
+ err = cache.Identities().Remove(iden1.Id().String()[:10])
+ require.NoError(t, err)
+ err = cache.Bugs().Remove(bug1.Id().String()[:10])
+ require.NoError(t, err)
+ require.Len(t, cache.bugs.cached, 0)
+ require.Len(t, cache.bugs.excerpts, 1)
+ require.Len(t, cache.identities.cached, 0)
+ require.Len(t, cache.identities.excerpts, 1)
+ require.Equal(t, uint64(1), indexCount(t, identity.Namespace))
+ require.Equal(t, uint64(1), indexCount(t, bug.Namespace))
+
+ _, err = cache.Identities().New("René Descartes", "rene@descartes.fr")
+ require.NoError(t, err)
+ _, _, err = cache.Bugs().NewRaw(iden2, time.Now().Unix(), "title", "message", nil, nil)
+ require.NoError(t, err)
+
+ err = cache.RemoveAll()
+ require.NoError(t, err)
+ require.Len(t, cache.bugs.cached, 0)
+ require.Len(t, cache.bugs.excerpts, 0)
+ require.Len(t, cache.identities.cached, 0)
+ require.Len(t, cache.identities.excerpts, 0)
+ require.Equal(t, uint64(0), indexCount(t, identity.Namespace))
+ require.Equal(t, uint64(0), indexCount(t, bug.Namespace))
+
// Close
require.NoError(t, cache.Close())
require.Empty(t, cache.bugs.cached)