aboutsummaryrefslogtreecommitdiffstats
path: root/operations/operations_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-25 17:56:58 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-25 17:56:58 +0200
commit40c6e64e4badfd543dc98237e1aeb3d8958cfe90 (patch)
tree03a992d71a1bfa3f069a5ef179649c0cf8479764 /operations/operations_test.go
parent5d7c3a76af85a857a6bb0bff5bac5282c0a9908f (diff)
downloadgit-bug-40c6e64e4badfd543dc98237e1aeb3d8958cfe90.tar.gz
cache: add raw edit functions to allow setting up the author, the timestamp and the metadatas
Diffstat (limited to 'operations/operations_test.go')
-rw-r--r--operations/operations_test.go53
1 files changed, 28 insertions, 25 deletions
diff --git a/operations/operations_test.go b/operations/operations_test.go
index b74dd8d1..b94c2c0c 100644
--- a/operations/operations_test.go
+++ b/operations/operations_test.go
@@ -2,6 +2,7 @@ package operations
import (
"testing"
+ "time"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/util/git"
@@ -13,12 +14,14 @@ func TestValidate(t *testing.T) {
Email: "rene@descartes.fr",
}
+ unix := time.Now().Unix()
+
good := []bug.Operation{
- NewCreateOp(rene, "title", "message", nil),
- NewSetTitleOp(rene, "title2", "title1"),
- NewAddCommentOp(rene, "message2", nil),
- NewSetStatusOp(rene, bug.ClosedStatus),
- NewLabelChangeOperation(rene, []bug.Label{"added"}, []bug.Label{"removed"}),
+ NewCreateOp(rene, unix, "title", "message", nil),
+ NewSetTitleOp(rene, unix, "title2", "title1"),
+ NewAddCommentOp(rene, unix, "message2", nil),
+ NewSetStatusOp(rene, unix, bug.ClosedStatus),
+ NewLabelChangeOperation(rene, unix, []bug.Label{"added"}, []bug.Label{"removed"}),
}
for _, op := range good {
@@ -29,11 +32,11 @@ func TestValidate(t *testing.T) {
bad := []bug.Operation{
// opbase
- NewSetStatusOp(bug.Person{Name: "", Email: "rene@descartes.fr"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René Descartes\u001b", Email: "rene@descartes.fr"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@descartes.fr\u001b"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René \nDescartes", Email: "rene@descartes.fr"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@\ndescartes.fr"}, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "", Email: "rene@descartes.fr"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René Descartes\u001b", Email: "rene@descartes.fr"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@descartes.fr\u001b"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René \nDescartes", Email: "rene@descartes.fr"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@\ndescartes.fr"}, unix, bug.ClosedStatus),
CreateOperation{OpBase: &bug.OpBase{
Author: rene,
UnixTime: 0,
@@ -43,21 +46,21 @@ func TestValidate(t *testing.T) {
Message: "message",
},
- NewCreateOp(rene, "multi\nline", "message", nil),
- NewCreateOp(rene, "title", "message", []git.Hash{git.Hash("invalid")}),
- NewCreateOp(rene, "title\u001b", "message", nil),
- NewCreateOp(rene, "title", "message\u001b", nil),
- NewSetTitleOp(rene, "multi\nline", "title1"),
- NewSetTitleOp(rene, "title", "multi\nline"),
- NewSetTitleOp(rene, "title\u001b", "title2"),
- NewSetTitleOp(rene, "title", "title2\u001b"),
- NewAddCommentOp(rene, "", nil),
- NewAddCommentOp(rene, "message\u001b", nil),
- NewAddCommentOp(rene, "message", []git.Hash{git.Hash("invalid")}),
- NewSetStatusOp(rene, 1000),
- NewSetStatusOp(rene, 0),
- NewLabelChangeOperation(rene, []bug.Label{}, []bug.Label{}),
- NewLabelChangeOperation(rene, []bug.Label{"multi\nline"}, []bug.Label{}),
+ NewCreateOp(rene, unix, "multi\nline", "message", nil),
+ NewCreateOp(rene, unix, "title", "message", []git.Hash{git.Hash("invalid")}),
+ NewCreateOp(rene, unix, "title\u001b", "message", nil),
+ NewCreateOp(rene, unix, "title", "message\u001b", nil),
+ NewSetTitleOp(rene, unix, "multi\nline", "title1"),
+ NewSetTitleOp(rene, unix, "title", "multi\nline"),
+ NewSetTitleOp(rene, unix, "title\u001b", "title2"),
+ NewSetTitleOp(rene, unix, "title", "title2\u001b"),
+ NewAddCommentOp(rene, unix, "", nil),
+ NewAddCommentOp(rene, unix, "message\u001b", nil),
+ NewAddCommentOp(rene, unix, "message", []git.Hash{git.Hash("invalid")}),
+ NewSetStatusOp(rene, unix, 1000),
+ NewSetStatusOp(rene, unix, 0),
+ NewLabelChangeOperation(rene, unix, []bug.Label{}, []bug.Label{}),
+ NewLabelChangeOperation(rene, unix, []bug.Label{"multi\nline"}, []bug.Label{}),
}
for i, op := range bad {