diff options
Diffstat (limited to 'bug/bug_actions_test.go')
-rw-r--r-- | bug/bug_actions_test.go | 259 |
1 files changed, 138 insertions, 121 deletions
diff --git a/bug/bug_actions_test.go b/bug/bug_actions_test.go index 39438ec7..4d42fb1d 100644 --- a/bug/bug_actions_test.go +++ b/bug/bug_actions_test.go @@ -1,8 +1,11 @@ package bug import ( + "time" + + "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/util/test" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "testing" ) @@ -11,20 +14,19 @@ func TestPushPull(t *testing.T) { repoA, repoB, remote := test.SetupReposAndRemote(t) defer test.CleanupRepos(repoA, repoB, remote) - err := rene.Commit(repoA) - assert.NoError(t, err) + reneA := identity.NewIdentity("René Descartes", "rene@descartes.fr") - bug1, _, err := Create(rene, unix, "bug1", "message") - assert.NoError(t, err) + bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message") + require.NoError(t, err) err = bug1.Commit(repoA) - assert.NoError(t, err) + require.NoError(t, err) // A --> remote --> B _, err = Push(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) err = Pull(repoB, "origin") - assert.NoError(t, err) + require.NoError(t, err) bugs := allBugs(t, ReadAllLocalBugs(repoB)) @@ -33,16 +35,19 @@ func TestPushPull(t *testing.T) { } // B --> remote --> A - bug2, _, err := Create(rene, unix, "bug2", "message") - assert.NoError(t, err) + reneB, err := identity.ReadLocal(repoA, reneA.Id()) + require.NoError(t, err) + + bug2, _, err := Create(reneB, time.Now().Unix(), "bug2", "message") + require.NoError(t, err) err = bug2.Commit(repoB) - assert.NoError(t, err) + require.NoError(t, err) _, err = Push(repoB, "origin") - assert.NoError(t, err) + require.NoError(t, err) err = Pull(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) bugs = allBugs(t, ReadAllLocalBugs(repoA)) @@ -76,38 +81,43 @@ func _RebaseTheirs(t testing.TB) { repoA, repoB, remote := test.SetupReposAndRemote(t) defer test.CleanupRepos(repoA, repoB, remote) - bug1, _, err := Create(rene, unix, "bug1", "message") - assert.NoError(t, err) + reneA := identity.NewIdentity("René Descartes", "rene@descartes.fr") + + bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message") + require.NoError(t, err) err = bug1.Commit(repoA) - assert.NoError(t, err) + require.NoError(t, err) // A --> remote _, err = Push(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) // remote --> B err = Pull(repoB, "origin") - assert.NoError(t, err) + require.NoError(t, err) bug2, err := ReadLocalBug(repoB, bug1.Id()) - assert.NoError(t, err) - - _, err = AddComment(bug2, rene, unix, "message2") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message3") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message4") - assert.NoError(t, err) + require.NoError(t, err) + + reneB, err := identity.ReadLocal(repoA, reneA.Id()) + require.NoError(t, err) + + _, err = AddComment(bug2, reneB, time.Now().Unix(), "message2") + require.NoError(t, err) + _, err = AddComment(bug2, reneB, time.Now().Unix(), "message3") + require.NoError(t, err) + _, err = AddComment(bug2, reneB, time.Now().Unix(), "message4") + require.NoError(t, err) err = bug2.Commit(repoB) - assert.NoError(t, err) + require.NoError(t, err) // B --> remote _, err = Push(repoB, "origin") - assert.NoError(t, err) + require.NoError(t, err) // remote --> A err = Pull(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) bugs := allBugs(t, ReadAllLocalBugs(repoB)) @@ -116,7 +126,7 @@ func _RebaseTheirs(t testing.TB) { } bug3, err := ReadLocalBug(repoA, bug1.Id()) - assert.NoError(t, err) + require.NoError(t, err) if nbOps(bug3) != 4 { t.Fatal("Unexpected number of operations") @@ -137,49 +147,51 @@ func _RebaseOurs(t testing.TB) { repoA, repoB, remote := test.SetupReposAndRemote(t) defer test.CleanupRepos(repoA, repoB, remote) - bug1, _, err := Create(rene, unix, "bug1", "message") - assert.NoError(t, err) + reneA := identity.NewIdentity("René Descartes", "rene@descartes.fr") + + bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message") + require.NoError(t, err) err = bug1.Commit(repoA) - assert.NoError(t, err) + require.NoError(t, err) // A --> remote _, err = Push(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) // remote --> B err = Pull(repoB, "origin") - assert.NoError(t, err) - - _, err = AddComment(bug1, rene, unix, "message2") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message3") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message4") - assert.NoError(t, err) + 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) err = bug1.Commit(repoA) - assert.NoError(t, err) - - _, err = AddComment(bug1, rene, unix, "message5") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message6") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message7") - assert.NoError(t, err) + 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) err = bug1.Commit(repoA) - assert.NoError(t, err) - - _, err = AddComment(bug1, rene, unix, "message8") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message9") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message10") - assert.NoError(t, err) + 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) err = bug1.Commit(repoA) - assert.NoError(t, err) + require.NoError(t, err) // remote --> A err = Pull(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) bugs := allBugs(t, ReadAllLocalBugs(repoA)) @@ -188,7 +200,7 @@ func _RebaseOurs(t testing.TB) { } bug2, err := ReadLocalBug(repoA, bug1.Id()) - assert.NoError(t, err) + require.NoError(t, err) if nbOps(bug2) != 10 { t.Fatal("Unexpected number of operations") @@ -218,83 +230,88 @@ func _RebaseConflict(t testing.TB) { repoA, repoB, remote := test.SetupReposAndRemote(t) defer test.CleanupRepos(repoA, repoB, remote) - bug1, _, err := Create(rene, unix, "bug1", "message") - assert.NoError(t, err) + reneA := identity.NewIdentity("René Descartes", "rene@descartes.fr") + + bug1, _, err := Create(reneA, time.Now().Unix(), "bug1", "message") + require.NoError(t, err) err = bug1.Commit(repoA) - assert.NoError(t, err) + require.NoError(t, err) // A --> remote _, err = Push(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) // remote --> B err = Pull(repoB, "origin") - assert.NoError(t, err) - - _, err = AddComment(bug1, rene, unix, "message2") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message3") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message4") - assert.NoError(t, err) + 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) err = bug1.Commit(repoA) - assert.NoError(t, err) - - _, err = AddComment(bug1, rene, unix, "message5") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message6") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message7") - assert.NoError(t, err) + 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) err = bug1.Commit(repoA) - assert.NoError(t, err) - - _, err = AddComment(bug1, rene, unix, "message8") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message9") - assert.NoError(t, err) - _, err = AddComment(bug1, rene, unix, "message10") - assert.NoError(t, err) + 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) err = bug1.Commit(repoA) - assert.NoError(t, err) + require.NoError(t, err) bug2, err := ReadLocalBug(repoB, bug1.Id()) - assert.NoError(t, err) - - _, err = AddComment(bug2, rene, unix, "message11") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message12") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message13") - assert.NoError(t, err) + 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) err = bug2.Commit(repoB) - assert.NoError(t, err) - - _, err = AddComment(bug2, rene, unix, "message14") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message15") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message16") - assert.NoError(t, err) + 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) err = bug2.Commit(repoB) - assert.NoError(t, err) - - _, err = AddComment(bug2, rene, unix, "message17") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message18") - assert.NoError(t, err) - _, err = AddComment(bug2, rene, unix, "message19") - assert.NoError(t, err) + 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) err = bug2.Commit(repoB) - assert.NoError(t, err) + require.NoError(t, err) // A --> remote _, err = Push(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) // remote --> B err = Pull(repoB, "origin") - assert.NoError(t, err) + require.NoError(t, err) bugs := allBugs(t, ReadAllLocalBugs(repoB)) @@ -303,7 +320,7 @@ func _RebaseConflict(t testing.TB) { } bug3, err := ReadLocalBug(repoB, bug1.Id()) - assert.NoError(t, err) + require.NoError(t, err) if nbOps(bug3) != 19 { t.Fatal("Unexpected number of operations") @@ -311,11 +328,11 @@ func _RebaseConflict(t testing.TB) { // B --> remote _, err = Push(repoB, "origin") - assert.NoError(t, err) + require.NoError(t, err) // remote --> A err = Pull(repoA, "origin") - assert.NoError(t, err) + require.NoError(t, err) bugs = allBugs(t, ReadAllLocalBugs(repoA)) @@ -324,7 +341,7 @@ func _RebaseConflict(t testing.TB) { } bug4, err := ReadLocalBug(repoA, bug1.Id()) - assert.NoError(t, err) + require.NoError(t, err) if nbOps(bug4) != 19 { t.Fatal("Unexpected number of operations") |