2018-09-28 21:39:39 +03:00
|
|
|
package bug
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
import (
|
2019-02-24 19:40:52 +03:00
|
|
|
"testing"
|
2019-02-16 19:32:30 +03:00
|
|
|
"time"
|
|
|
|
|
2019-11-19 02:28:06 +03:00
|
|
|
"github.com/stretchr/testify/assert"
|
2019-02-16 19:32:30 +03:00
|
|
|
"github.com/stretchr/testify/require"
|
2019-05-27 22:14:55 +03:00
|
|
|
|
|
|
|
"github.com/MichaelMure/git-bug/identity"
|
|
|
|
"github.com/MichaelMure/git-bug/repository"
|
2018-07-25 19:02:11 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestPushPull(t *testing.T) {
|
2021-01-25 14:39:34 +03:00
|
|
|
repoA, repoB, remote := repository.SetupGoGitReposAndRemote()
|
2020-06-23 19:02:54 +03:00
|
|
|
defer repository.CleanupTestRepos(repoA, repoB, remote)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-11-08 21:15:06 +03:00
|
|
|
reneA, err := identity.NewIdentity(repoA, "René Descartes", "rene@descartes.fr")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = reneA.Commit(repoA)
|
2020-09-16 17:22:02 +03:00
|
|
|
require.NoError(t, err)
|
2019-01-19 21:23:31 +03:00
|
|
|
|
2019-02-16 19:32:30 +03:00
|
|
|
bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message")
|
|
|
|
require.NoError(t, err)
|
2019-11-19 02:28:06 +03:00
|
|
|
assert.True(t, bug1.NeedCommit())
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2019-11-19 02:28:06 +03:00
|
|
|
assert.False(t, bug1.NeedCommit())
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2019-03-25 23:09:56 +03:00
|
|
|
// distribute the identity
|
|
|
|
_, err = identity.Push(repoA, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = identity.Pull(repoB, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2018-07-25 19:02:11 +03:00
|
|
|
// A --> remote --> B
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bugs := allBugs(t, ReadAllLocal(repoB))
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if len(bugs) != 1 {
|
|
|
|
t.Fatal("Unexpected number of bugs")
|
|
|
|
}
|
|
|
|
|
|
|
|
// B --> remote --> A
|
2019-02-16 19:32:30 +03:00
|
|
|
reneB, err := identity.ReadLocal(repoA, reneA.Id())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
bug2, _, err := Create(reneB, time.Now().Unix(), "bug2", "message")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug2.Commit(repoB)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bugs = allBugs(t, ReadAllLocal(repoA))
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if len(bugs) != 2 {
|
|
|
|
t.Fatal("Unexpected number of bugs")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-28 21:39:39 +03:00
|
|
|
func allBugs(t testing.TB, bugs <-chan StreamedBug) []*Bug {
|
|
|
|
var result []*Bug
|
2018-07-25 19:02:11 +03:00
|
|
|
for streamed := range bugs {
|
|
|
|
if streamed.Err != nil {
|
|
|
|
t.Fatal(streamed.Err)
|
|
|
|
}
|
|
|
|
result = append(result, streamed.Bug)
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRebaseTheirs(t *testing.T) {
|
2018-08-19 21:40:50 +03:00
|
|
|
_RebaseTheirs(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkRebaseTheirs(b *testing.B) {
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
|
|
_RebaseTheirs(b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func _RebaseTheirs(t testing.TB) {
|
2021-01-25 14:39:34 +03:00
|
|
|
repoA, repoB, remote := repository.SetupGoGitReposAndRemote()
|
2020-06-23 19:02:54 +03:00
|
|
|
defer repository.CleanupTestRepos(repoA, repoB, remote)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-11-08 21:15:06 +03:00
|
|
|
reneA, err := identity.NewIdentity(repoA, "René Descartes", "rene@descartes.fr")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = reneA.Commit(repoA)
|
2020-09-16 17:22:02 +03:00
|
|
|
require.NoError(t, err)
|
2019-02-16 19:32:30 +03:00
|
|
|
|
|
|
|
bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message")
|
|
|
|
require.NoError(t, err)
|
2019-11-19 02:28:06 +03:00
|
|
|
assert.True(t, bug1.NeedCommit())
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2019-11-19 02:28:06 +03:00
|
|
|
assert.False(t, bug1.NeedCommit())
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2019-03-25 23:09:56 +03:00
|
|
|
// distribute the identity
|
|
|
|
_, err = identity.Push(repoA, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = identity.Pull(repoB, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2018-07-25 19:02:11 +03:00
|
|
|
// A --> remote
|
2019-03-25 23:09:56 +03:00
|
|
|
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// remote --> B
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bug2, err := ReadLocal(repoB, bug1.Id())
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2019-11-19 02:28:06 +03:00
|
|
|
assert.False(t, bug2.NeedCommit())
|
2019-02-16 19:32:30 +03:00
|
|
|
|
|
|
|
reneB, err := identity.ReadLocal(repoA, reneA.Id())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message2")
|
|
|
|
require.NoError(t, err)
|
2019-11-19 02:28:06 +03:00
|
|
|
assert.True(t, bug2.NeedCommit())
|
2019-02-16 19:32:30 +03:00
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message3")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message4")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug2.Commit(repoB)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2019-11-19 02:28:06 +03:00
|
|
|
assert.False(t, bug2.NeedCommit())
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// B --> remote
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// remote --> A
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bugs := allBugs(t, ReadAllLocal(repoB))
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if len(bugs) != 1 {
|
|
|
|
t.Fatal("Unexpected number of bugs")
|
|
|
|
}
|
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bug3, err := ReadLocal(repoA, bug1.Id())
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if nbOps(bug3) != 4 {
|
|
|
|
t.Fatal("Unexpected number of operations")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRebaseOurs(t *testing.T) {
|
2018-08-19 21:40:50 +03:00
|
|
|
_RebaseOurs(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkRebaseOurs(b *testing.B) {
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
|
|
_RebaseOurs(b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func _RebaseOurs(t testing.TB) {
|
2021-01-25 14:39:34 +03:00
|
|
|
repoA, repoB, remote := repository.SetupGoGitReposAndRemote()
|
2020-06-23 19:02:54 +03:00
|
|
|
defer repository.CleanupTestRepos(repoA, repoB, remote)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-11-08 21:15:06 +03:00
|
|
|
reneA, err := identity.NewIdentity(repoA, "René Descartes", "rene@descartes.fr")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = reneA.Commit(repoA)
|
2020-09-16 17:22:02 +03:00
|
|
|
require.NoError(t, err)
|
2019-02-16 19:32:30 +03:00
|
|
|
|
|
|
|
bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2019-03-25 23:09:56 +03:00
|
|
|
// distribute the identity
|
|
|
|
_, err = identity.Push(repoA, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = identity.Pull(repoB, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2018-07-25 19:02:11 +03:00
|
|
|
// A --> remote
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// remote --> B
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message2")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message3")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message4")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message5")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message6")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message7")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message8")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message9")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message10")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// remote --> A
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bugs := allBugs(t, ReadAllLocal(repoA))
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if len(bugs) != 1 {
|
|
|
|
t.Fatal("Unexpected number of bugs")
|
|
|
|
}
|
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bug2, err := ReadLocal(repoA, bug1.Id())
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if nbOps(bug2) != 10 {
|
|
|
|
t.Fatal("Unexpected number of operations")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-28 21:39:39 +03:00
|
|
|
func nbOps(b *Bug) int {
|
|
|
|
it := NewOperationIterator(b)
|
2018-07-25 19:02:11 +03:00
|
|
|
counter := 0
|
|
|
|
for it.Next() {
|
|
|
|
counter++
|
|
|
|
}
|
|
|
|
return counter
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRebaseConflict(t *testing.T) {
|
2018-08-19 21:40:50 +03:00
|
|
|
_RebaseConflict(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkRebaseConflict(b *testing.B) {
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
|
|
_RebaseConflict(b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func _RebaseConflict(t testing.TB) {
|
2021-01-25 14:39:34 +03:00
|
|
|
repoA, repoB, remote := repository.SetupGoGitReposAndRemote()
|
2020-06-23 19:02:54 +03:00
|
|
|
defer repository.CleanupTestRepos(repoA, repoB, remote)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-11-08 21:15:06 +03:00
|
|
|
reneA, err := identity.NewIdentity(repoA, "René Descartes", "rene@descartes.fr")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = reneA.Commit(repoA)
|
2020-09-16 17:22:02 +03:00
|
|
|
require.NoError(t, err)
|
2019-02-16 19:32:30 +03:00
|
|
|
|
|
|
|
bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2019-03-25 23:09:56 +03:00
|
|
|
// distribute the identity
|
|
|
|
_, err = identity.Push(repoA, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = identity.Pull(repoB, "origin")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2018-07-25 19:02:11 +03:00
|
|
|
// A --> remote
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// remote --> B
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message2")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message3")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message4")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message5")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message6")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message7")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message8")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message9")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug1, reneA, time.Now().Unix(), "message10")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug1.Commit(repoA)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bug2, err := ReadLocal(repoB, bug1.Id())
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
reneB, err := identity.ReadLocal(repoA, reneA.Id())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message11")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message12")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message13")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug2.Commit(repoB)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message14")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message15")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message16")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug2.Commit(repoB)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message17")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message18")
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = AddComment(bug2, reneB, time.Now().Unix(), "message19")
|
|
|
|
require.NoError(t, err)
|
2018-09-13 13:43:47 +03:00
|
|
|
err = bug2.Commit(repoB)
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// A --> remote
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// remote --> B
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bugs := allBugs(t, ReadAllLocal(repoB))
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if len(bugs) != 1 {
|
|
|
|
t.Fatal("Unexpected number of bugs")
|
|
|
|
}
|
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bug3, err := ReadLocal(repoB, bug1.Id())
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if nbOps(bug3) != 19 {
|
|
|
|
t.Fatal("Unexpected number of operations")
|
|
|
|
}
|
|
|
|
|
|
|
|
// B --> remote
|
2018-09-28 21:39:39 +03:00
|
|
|
_, err = Push(repoB, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
// remote --> A
|
2018-09-28 21:39:39 +03:00
|
|
|
err = Pull(repoA, "origin")
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bugs = allBugs(t, ReadAllLocal(repoA))
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if len(bugs) != 1 {
|
|
|
|
t.Fatal("Unexpected number of bugs")
|
|
|
|
}
|
|
|
|
|
2020-09-16 17:22:02 +03:00
|
|
|
bug4, err := ReadLocal(repoA, bug1.Id())
|
2019-02-16 19:32:30 +03:00
|
|
|
require.NoError(t, err)
|
2018-07-25 19:02:11 +03:00
|
|
|
|
|
|
|
if nbOps(bug4) != 19 {
|
|
|
|
t.Fatal("Unexpected number of operations")
|
|
|
|
}
|
|
|
|
}
|