forked from go-gorm/gorm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
search_test.go
30 lines (23 loc) · 668 Bytes
/
search_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package gorm
import (
"reflect"
"testing"
)
func TestCloneSearch(t *testing.T) {
s := new(search)
s.Where("name = ?", "jinzhu").Order("name").Attrs("name", "jinzhu").Select("name, age")
s1 := s.clone()
s1.Where("age = ?", 20).Order("age").Attrs("email", "[email protected]").Select("email")
if reflect.DeepEqual(s.whereConditions, s1.whereConditions) {
t.Errorf("Where should be copied")
}
if reflect.DeepEqual(s.orders, s1.orders) {
t.Errorf("Order should be copied")
}
if reflect.DeepEqual(s.initAttrs, s1.initAttrs) {
t.Errorf("InitAttrs should be copied")
}
if reflect.DeepEqual(s.Select, s1.Select) {
t.Errorf("selectStr should be copied")
}
}