diff options
author | Michael Muré <batolettre@gmail.com> | 2019-04-02 22:01:42 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-04-02 22:01:42 +0200 |
commit | 96987bf6ae528024b1c34006ce7820e3144f3914 (patch) | |
tree | 14a6d1ff3971ec58b0fb45e3471bf16300be9318 /cache/repo_cache_test.go | |
parent | 9765465b607a8f060a9386cb3cb84c94d0232009 (diff) | |
download | git-bug-96987bf6ae528024b1c34006ce7820e3144f3914.tar.gz |
cache: add a push/pull test
Diffstat (limited to 'cache/repo_cache_test.go')
-rw-r--r-- | cache/repo_cache_test.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cache/repo_cache_test.go b/cache/repo_cache_test.go index c90ad28e..8f4d47d0 100644 --- a/cache/repo_cache_test.go +++ b/cache/repo_cache_test.go @@ -99,3 +99,58 @@ func TestCache(t *testing.T) { _, err = cache.ResolveBugPrefix(bug1.Id()[:10]) require.NoError(t, err) } + +func TestPushPull(t *testing.T) { + repoA, repoB, remote := test.SetupReposAndRemote(t) + defer test.CleanupRepos(repoA, repoB, remote) + + cacheA, err := NewRepoCache(repoA) + require.NoError(t, err) + + cacheB, err := NewRepoCache(repoB) + require.NoError(t, err) + + // Create, set and get user identity + reneA, err := cacheA.NewIdentity("René Descartes", "rene@descartes.fr") + require.NoError(t, err) + err = cacheA.SetUserIdentity(reneA) + require.NoError(t, err) + + // distribute the identity + _, err = cacheA.Push("origin") + require.NoError(t, err) + err = cacheB.Pull("origin") + require.NoError(t, err) + + // Create a bug in A + _, err = cacheA.NewBug("bug1", "message") + require.NoError(t, err) + + // A --> remote --> B + _, err = cacheA.Push("origin") + require.NoError(t, err) + + err = cacheB.Pull("origin") + require.NoError(t, err) + + require.Len(t, cacheB.AllBugsIds(), 1) + + // retrieve and set identity + reneB, err := cacheB.ResolveIdentity(reneA.Id()) + require.NoError(t, err) + + err = cacheB.SetUserIdentity(reneB) + require.NoError(t, err) + + // B --> remote --> A + _, err = cacheB.NewBug("bug2", "message") + require.NoError(t, err) + + _, err = cacheB.Push("origin") + require.NoError(t, err) + + err = cacheA.Pull("origin") + require.NoError(t, err) + + require.Len(t, cacheA.AllBugsIds(), 2) +} |