git-bug/operations/create_test.go

37 lines
671 B
Go
Raw Normal View History

2018-07-12 22:31:41 +03:00
package operations
import (
"github.com/MichaelMure/git-bug/bug"
"reflect"
"testing"
"time"
2018-07-12 22:31:41 +03:00
)
func TestCreate(t *testing.T) {
snapshot := bug.Snapshot{}
var rene = bug.Person{
Name: "René Descartes",
Email: "rene@descartes.fr",
}
unix := time.Now().Unix()
create := NewCreateOp(rene, unix, "title", "message", nil)
2018-07-12 22:31:41 +03:00
snapshot = create.Apply(snapshot)
expected := bug.Snapshot{
Title: "title",
Comments: []bug.Comment{
{Author: rene, Message: "message", UnixTime: create.UnixTime},
2018-07-12 22:31:41 +03:00
},
2018-08-01 03:15:40 +03:00
Author: rene,
CreatedAt: create.Time(),
2018-07-12 22:31:41 +03:00
}
if !reflect.DeepEqual(snapshot, expected) {
2018-07-15 00:03:43 +03:00
t.Fatalf("%v different than %v", snapshot, expected)
2018-07-12 22:31:41 +03:00
}
}