diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-12 21:31:41 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-12 21:32:11 +0200 |
commit | e02294c8f372156945bbc43d70d4d36a07a3fbcf (patch) | |
tree | ec928f35309280db8ec6f03640b9b6b2ac3caad6 /bug/operations/operation_test.go | |
parent | 3aecdf2c2da9017513ca04a183089099fb3677d5 (diff) | |
download | git-bug-e02294c8f372156945bbc43d70d4d36a07a3fbcf.tar.gz |
add the first 2 operations
Diffstat (limited to 'bug/operations/operation_test.go')
-rw-r--r-- | bug/operations/operation_test.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/bug/operations/operation_test.go b/bug/operations/operation_test.go new file mode 100644 index 00000000..1bd15f78 --- /dev/null +++ b/bug/operations/operation_test.go @@ -0,0 +1,57 @@ +package operations + +import ( + "github.com/MichaelMure/git-bug/bug" + "testing" +) + +// Different type with the same fields +type CreateOperation2 struct { + Title string + Message string +} + +func (op CreateOperation2) OpType() OperationType { + return UNKNOW +} + +func (op CreateOperation2) Apply(snapshot bug.Snapshot) bug.Snapshot { + // no-op + return snapshot +} + +func TestOperationsEquality(t *testing.T) { + var rene = bug.Person{ + Name: "René Descartes", + Email: "rene@descartes.fr", + } + + var A Operation = NewCreateOp(rene, "title", "message") + var B Operation = NewCreateOp(rene, "title", "message") + var C Operation = NewCreateOp(rene, "title", "different message") + + if A != B { + t.Fatal("Equal value operations should be tested equals") + } + + if A == C { + t.Fatal("Different value operations should be tested different") + } + + D := CreateOperation2{Title: "title", Message: "message"} + + if A == D { + t.Fatal("Operations equality should handle the type") + } + + var isaac = bug.Person{ + Name: "Isaac Newton", + Email: "isaac@newton.uk", + } + + var E Operation = NewCreateOp(isaac, "title", "message") + + if A == E { + t.Fatal("Operation equality should handle the author") + } +} |