OSDN Git Service

feat: init cross_tx keepers (#146)
[bytom/vapor.git] / vendor / github.com / jinzhu / gorm / search_test.go
1 package gorm
2
3 import (
4         "reflect"
5         "testing"
6 )
7
8 func TestCloneSearch(t *testing.T) {
9         s := new(search)
10         s.Where("name = ?", "jinzhu").Order("name").Attrs("name", "jinzhu").Select("name, age")
11
12         s1 := s.clone()
13         s1.Where("age = ?", 20).Order("age").Attrs("email", "a@e.org").Select("email")
14
15         if reflect.DeepEqual(s.whereConditions, s1.whereConditions) {
16                 t.Errorf("Where should be copied")
17         }
18
19         if reflect.DeepEqual(s.orders, s1.orders) {
20                 t.Errorf("Order should be copied")
21         }
22
23         if reflect.DeepEqual(s.initAttrs, s1.initAttrs) {
24                 t.Errorf("InitAttrs should be copied")
25         }
26
27         if reflect.DeepEqual(s.Select, s1.Select) {
28                 t.Errorf("selectStr should be copied")
29         }
30 }