2018-07-12 22:31:41 +03:00
|
|
|
package operations
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/MichaelMure/git-bug/bug"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCreate(t *testing.T) {
|
|
|
|
snapshot := bug.Snapshot{}
|
|
|
|
|
|
|
|
var rene = bug.Person{
|
|
|
|
Name: "René Descartes",
|
|
|
|
Email: "rene@descartes.fr",
|
|
|
|
}
|
|
|
|
|
2018-08-03 00:45:40 +03:00
|
|
|
create := NewCreateOp(rene, "title", "message", nil)
|
2018-07-12 22:31:41 +03:00
|
|
|
|
|
|
|
snapshot = create.Apply(snapshot)
|
|
|
|
|
|
|
|
expected := bug.Snapshot{
|
|
|
|
Title: "title",
|
|
|
|
Comments: []bug.Comment{
|
2018-09-10 20:03:17 +03:00
|
|
|
{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
|
|
|
}
|
|
|
|
}
|