From d10c76469d40f13e27739fd363145e89bf74c3e0 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 19 Jan 2019 19:23:31 +0100 Subject: identity: somewhat getting closer ! --- bug/bug_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'bug/bug_test.go') diff --git a/bug/bug_test.go b/bug/bug_test.go index 0fd373d5..41a5b03d 100644 --- a/bug/bug_test.go +++ b/bug/bug_test.go @@ -2,7 +2,6 @@ package bug import ( "github.com/MichaelMure/git-bug/repository" - "github.com/go-test/deep" "github.com/stretchr/testify/assert" "testing" @@ -87,8 +86,5 @@ func TestBugSerialisation(t *testing.T) { } } - deep.CompareUnexportedFields = true - if diff := deep.Equal(bug1, bug2); diff != nil { - t.Fatal(diff) - } + assert.Equal(t, bug1, bug2) } -- cgit From 21048e785d976a04e26798e4a385ee675c95b88f Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 6 Feb 2019 22:06:42 +0100 Subject: identity: wip --- bug/bug_test.go | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'bug/bug_test.go') diff --git a/bug/bug_test.go b/bug/bug_test.go index 41a5b03d..001bfc56 100644 --- a/bug/bug_test.go +++ b/bug/bug_test.go @@ -55,7 +55,7 @@ func TestBugValidity(t *testing.T) { } } -func TestBugSerialisation(t *testing.T) { +func TestBugCommitLoad(t *testing.T) { bug1 := NewBug() bug1.Append(createOp) @@ -69,22 +69,30 @@ func TestBugSerialisation(t *testing.T) { assert.Nil(t, err) bug2, err := ReadLocalBug(repo, bug1.Id()) - if err != nil { - t.Error(err) - } + assert.NoError(t, err) + equivalentBug(t, bug1, bug2) - // ignore some fields - bug2.packs[0].commitHash = bug1.packs[0].commitHash - for i := range bug1.packs[0].Operations { - bug2.packs[0].Operations[i].base().hash = bug1.packs[0].Operations[i].base().hash - } + // add more op + + bug1.Append(setTitleOp) + bug1.Append(addCommentOp) + + err = bug1.Commit(repo) + assert.Nil(t, err) + + bug3, err := ReadLocalBug(repo, bug1.Id()) + assert.NoError(t, err) + equivalentBug(t, bug1, bug3) +} + +func equivalentBug(t *testing.T, expected, actual *Bug) { + assert.Equal(t, len(expected.packs), len(actual.packs)) - // check hashes - for i := range bug1.packs[0].Operations { - if !bug2.packs[0].Operations[i].base().hash.IsValid() { - t.Fatal("invalid hash") + for i := range expected.packs { + for j := range expected.packs[i].Operations { + actual.packs[i].Operations[j].base().hash = expected.packs[i].Operations[j].base().hash } } - assert.Equal(t, bug1, bug2) + assert.Equal(t, expected, actual) } -- cgit From d2483d83dd52365741f51eca106aa18c4e8d6420 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 16 Feb 2019 17:32:30 +0100 Subject: identity: I can compile again !! --- bug/bug_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'bug/bug_test.go') diff --git a/bug/bug_test.go b/bug/bug_test.go index 001bfc56..e104f921 100644 --- a/bug/bug_test.go +++ b/bug/bug_test.go @@ -1,6 +1,9 @@ package bug import ( + "time" + + "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" "github.com/stretchr/testify/assert" @@ -12,6 +15,9 @@ func TestBugId(t *testing.T) { bug1 := NewBug() + rene := identity.NewIdentity("René Descartes", "rene@descartes.fr") + createOp := NewCreateOp(rene, time.Now().Unix(), "title", "message", nil) + bug1.Append(createOp) err := bug1.Commit(mockRepo) @@ -28,6 +34,9 @@ func TestBugValidity(t *testing.T) { bug1 := NewBug() + rene := identity.NewIdentity("René Descartes", "rene@descartes.fr") + createOp := NewCreateOp(rene, time.Now().Unix(), "title", "message", nil) + if bug1.Validate() == nil { t.Fatal("Empty bug should be invalid") } @@ -58,6 +67,11 @@ func TestBugValidity(t *testing.T) { func TestBugCommitLoad(t *testing.T) { bug1 := NewBug() + rene := identity.NewIdentity("René Descartes", "rene@descartes.fr") + createOp := NewCreateOp(rene, time.Now().Unix(), "title", "message", nil) + setTitleOp := NewSetTitleOp(rene, time.Now().Unix(), "title2", "title1") + addCommentOp := NewAddCommentOp(rene, time.Now().Unix(), "message2", nil) + bug1.Append(createOp) bug1.Append(setTitleOp) bug1.Append(setTitleOp) -- cgit From 475b7b4c490bc3729772932f2d7bbcabb8f781a7 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 24 Feb 2019 17:40:52 +0100 Subject: a round of cleanup --- bug/bug_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bug/bug_test.go') diff --git a/bug/bug_test.go b/bug/bug_test.go index e104f921..4c3952eb 100644 --- a/bug/bug_test.go +++ b/bug/bug_test.go @@ -1,13 +1,12 @@ package bug import ( + "testing" "time" "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" "github.com/stretchr/testify/assert" - - "testing" ) func TestBugId(t *testing.T) { -- cgit