create_test.go

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