gorm/search_test.go

31 lines
672 B
Go
Raw Normal View History

2013-11-16 05:12:22 +04:00
package gorm
import (
"reflect"
"testing"
)
func TestCloneSearch(t *testing.T) {
s := new(search)
s.where("name = ?", "jinzhu").order("name").attrs("name", "jinzhu").selects("name, age")
s1 := s.clone()
s1.where("age = ?", 20).order("age").attrs("email", "a@e.org").selects("email")
2014-01-28 12:56:51 +04:00
if reflect.DeepEqual(s.WhereConditions, s1.WhereConditions) {
2013-11-16 05:12:22 +04:00
t.Errorf("Where should be copied")
}
2014-01-28 12:56:51 +04:00
if reflect.DeepEqual(s.Orders, s1.Orders) {
2013-11-16 05:12:22 +04:00
t.Errorf("Order should be copied")
}
2014-01-28 12:56:51 +04:00
if reflect.DeepEqual(s.InitAttrs, s1.InitAttrs) {
t.Errorf("InitAttrs should be copied")
2013-11-16 05:12:22 +04:00
}
if reflect.DeepEqual(s.Selects, s1.Selects) {
2013-11-16 05:12:22 +04:00
t.Errorf("selectStr should be copied")
}
}