1package operations
2
3import (
4 "github.com/MichaelMure/git-bug/bug"
5 "reflect"
6 "testing"
7 "time"
8)
9
10func TestCreate(t *testing.T) {
11 snapshot := bug.Snapshot{}
12
13 var rene = bug.Person{
14 Name: "René Descartes",
15 Email: "rene@descartes.fr",
16 }
17
18 unix := time.Now().Unix()
19
20 create := NewCreateOp(rene, unix, "title", "message", nil)
21
22 snapshot = create.Apply(snapshot)
23
24 expected := bug.Snapshot{
25 Title: "title",
26 Comments: []bug.Comment{
27 {Author: rene, Message: "message", UnixTime: create.UnixTime},
28 },
29 Author: rene,
30 CreatedAt: create.Time(),
31 }
32
33 if !reflect.DeepEqual(snapshot, expected) {
34 t.Fatalf("%v different than %v", snapshot, expected)
35 }
36}