aboutsummaryrefslogblamecommitdiffstats
path: root/bug/op_create_test.go
blob: 2c5ae35b8d8f9dd5088d2a166d9186b95a6f5ea2 (plain) (tree)
1
2
3
4
5
6
7
8
9
           

        

                 
              


                               
                              
 
                          



                                           


                                                                  
 
                               
 
                             
                               
                                    
                                                                                      
                  

                                         


                                                   
                                                                    

         
package bug

import (
	"reflect"
	"testing"
	"time"
)

func TestCreate(t *testing.T) {
	snapshot := Snapshot{}

	var rene = Person{
		Name:  "René Descartes",
		Email: "rene@descartes.fr",
	}

	unix := time.Now().Unix()

	create := NewCreateOp(rene, unix, "title", "message", nil)

	create.Apply(&snapshot)

	expected := Snapshot{
		Title: "title",
		Comments: []Comment{
			{Author: rene, Message: "message", UnixTime: create.UnixTime},
		},
		Author:    rene,
		CreatedAt: create.Time(),
	}

	if !reflect.DeepEqual(snapshot, expected) {
		t.Fatalf("%v different than %v", snapshot, expected)
	}
}