@@ -47,35 +47,34 @@ import (
4747)
4848
4949func TestHasManyAssociation (t * testing.T ) {
50- t .Skip ()
5150 user := * GetUser ("hasmany" , Config {Pets : 2 })
5251
5352 if err := DB .Create (& user ).Error ; err != nil {
5453 t .Fatalf ("errors happened when create: %v" , err )
5554 }
5655
57- CheckUser (t , user , user )
56+ CheckUserSkipUpdatedAt (t , user , user )
5857
5958 // Find
6059 var user2 User
61- DB .Find (& user2 , "id = ?" , user .ID )
60+ DB .Find (& user2 , "\" id \" = ?" , user .ID )
6261 DB .Model (& user2 ).Association ("Pets" ).Find (& user2 .Pets )
63- CheckUser (t , user2 , user )
62+ CheckUserSkipUpdatedAt (t , user2 , user )
6463
6564 var pets []Pet
66- DB .Model (& user ).Where ("name = ?" , user .Pets [0 ].Name ).Association ("Pets" ).Find (& pets )
65+ DB .Model (& user ).Where ("\" name\" = ?" , user .Pets [0 ].Name ).Association ("Pets" ).Find (& pets )
6766
6867 if len (pets ) != 1 {
6968 t .Fatalf ("should only find one pets, but got %v" , len (pets ))
7069 }
7170
7271 CheckPet (t , pets [0 ], * user .Pets [0 ])
7372
74- if count := DB .Model (& user ).Where ("name = ?" , user .Pets [1 ].Name ).Association ("Pets" ).Count (); count != 1 {
73+ if count := DB .Model (& user ).Where ("\" name\" = ?" , user .Pets [1 ].Name ).Association ("Pets" ).Count (); count != 1 {
7574 t .Fatalf ("should only find one pets, but got %v" , count )
7675 }
7776
78- if count := DB .Model (& user ).Where ("name = ?" , "not found" ).Association ("Pets" ).Count (); count != 0 {
77+ if count := DB .Model (& user ).Where ("\" name\" = ?" , "not found" ).Association ("Pets" ).Count (); count != 0 {
7978 t .Fatalf ("should only find no pet with invalid conditions, but got %v" , count )
8079 }
8180
@@ -94,7 +93,7 @@ func TestHasManyAssociation(t *testing.T) {
9493 }
9594
9695 user .Pets = append (user .Pets , & pet )
97- CheckUser (t , user2 , user )
96+ CheckUserSkipUpdatedAt (t , user2 , user )
9897
9998 AssertAssociationCount (t , user , "Pets" , 3 , "AfterAppend" )
10099
@@ -113,7 +112,7 @@ func TestHasManyAssociation(t *testing.T) {
113112 user .Pets = append (user .Pets , & pet )
114113 }
115114
116- CheckUser (t , user2 , user )
115+ CheckUserSkipUpdatedAt (t , user2 , user )
117116
118117 AssertAssociationCount (t , user , "Pets" , 5 , "AfterAppendSlice" )
119118
@@ -129,7 +128,7 @@ func TestHasManyAssociation(t *testing.T) {
129128 }
130129
131130 user .Pets = []* Pet {& pet2 }
132- CheckUser (t , user2 , user )
131+ CheckUserSkipUpdatedAt (t , user2 , user )
133132
134133 AssertAssociationCount (t , user2 , "Pets" , 1 , "AfterReplace" )
135134
@@ -160,20 +159,19 @@ func TestHasManyAssociation(t *testing.T) {
160159}
161160
162161func TestSingleTableHasManyAssociation (t * testing.T ) {
163- t .Skip ()
164162 user := * GetUser ("hasmany" , Config {Team : 2 })
165163
166164 if err := DB .Create (& user ).Error ; err != nil {
167165 t .Fatalf ("errors happened when create: %v" , err )
168166 }
169167
170- CheckUser (t , user , user )
168+ CheckUserSkipUpdatedAt (t , user , user )
171169
172170 // Find
173171 var user2 User
174- DB .Find (& user2 , "id = ?" , user .ID )
172+ DB .Find (& user2 , "\" id \" = ?" , user .ID )
175173 DB .Model (& user2 ).Association ("Team" ).Find (& user2 .Team )
176- CheckUser (t , user2 , user )
174+ CheckUserSkipUpdatedAt (t , user2 , user )
177175
178176 // Count
179177 AssertAssociationCount (t , user , "Team" , 2 , "" )
@@ -190,7 +188,7 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
190188 }
191189
192190 user .Team = append (user .Team , team )
193- CheckUser (t , user2 , user )
191+ CheckUserSkipUpdatedAt (t , user2 , user )
194192
195193 AssertAssociationCount (t , user , "Team" , 3 , "AfterAppend" )
196194
@@ -209,7 +207,7 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
209207 user .Team = append (user .Team , team )
210208 }
211209
212- CheckUser (t , user2 , user )
210+ CheckUserSkipUpdatedAt (t , user2 , user )
213211
214212 AssertAssociationCount (t , user , "Team" , 5 , "AfterAppendSlice" )
215213
@@ -225,7 +223,7 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
225223 }
226224
227225 user .Team = []User {team2 }
228- CheckUser (t , user2 , user )
226+ CheckUserSkipUpdatedAt (t , user2 , user )
229227
230228 AssertAssociationCount (t , user2 , "Team" , 1 , "AfterReplace" )
231229
@@ -256,7 +254,6 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
256254}
257255
258256func TestHasManyAssociationForSlice (t * testing.T ) {
259- t .Skip ()
260257 users := []User {
261258 * GetUser ("slice-hasmany-1" , Config {Pets : 2 }),
262259 * GetUser ("slice-hasmany-2" , Config {Pets : 0 }),
@@ -311,7 +308,6 @@ func TestHasManyAssociationForSlice(t *testing.T) {
311308}
312309
313310func TestSingleTableHasManyAssociationForSlice (t * testing.T ) {
314- t .Skip ()
315311 users := []User {
316312 * GetUser ("slice-hasmany-1" , Config {Team : 2 }),
317313 * GetUser ("slice-hasmany-2" , Config {Team : 0 }),
@@ -368,20 +364,19 @@ func TestSingleTableHasManyAssociationForSlice(t *testing.T) {
368364}
369365
370366func TestPolymorphicHasManyAssociation (t * testing.T ) {
371- t .Skip ()
372367 user := * GetUser ("hasmany" , Config {Toys : 2 })
373368
374369 if err := DB .Create (& user ).Error ; err != nil {
375370 t .Fatalf ("errors happened when create: %v" , err )
376371 }
377372
378- CheckUser (t , user , user )
373+ CheckUserSkipUpdatedAt (t , user , user )
379374
380375 // Find
381376 var user2 User
382- DB .Find (& user2 , "id = ?" , user .ID )
377+ DB .Find (& user2 , "\" id \" = ?" , user .ID )
383378 DB .Model (& user2 ).Association ("Toys" ).Find (& user2 .Toys )
384- CheckUser (t , user2 , user )
379+ CheckUserSkipUpdatedAt (t , user2 , user )
385380
386381 // Count
387382 AssertAssociationCount (t , user , "Toys" , 2 , "" )
@@ -398,7 +393,7 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
398393 }
399394
400395 user .Toys = append (user .Toys , toy )
401- CheckUser (t , user2 , user )
396+ CheckUserSkipUpdatedAt (t , user2 , user )
402397
403398 AssertAssociationCount (t , user , "Toys" , 3 , "AfterAppend" )
404399
@@ -417,7 +412,7 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
417412 user .Toys = append (user .Toys , toy )
418413 }
419414
420- CheckUser (t , user2 , user )
415+ CheckUserSkipUpdatedAt (t , user2 , user )
421416
422417 AssertAssociationCount (t , user , "Toys" , 5 , "AfterAppendSlice" )
423418
@@ -433,7 +428,7 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
433428 }
434429
435430 user .Toys = []Toy {toy2 }
436- CheckUser (t , user2 , user )
431+ CheckUserSkipUpdatedAt (t , user2 , user )
437432
438433 AssertAssociationCount (t , user2 , "Toys" , 1 , "AfterReplace" )
439434
@@ -464,7 +459,6 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
464459}
465460
466461func TestPolymorphicHasManyAssociationForSlice (t * testing.T ) {
467- t .Skip ()
468462 users := []User {
469463 * GetUser ("slice-hasmany-1" , Config {Toys : 2 }),
470464 * GetUser ("slice-hasmany-2" , Config {Toys : 0 , Tools : 2 }),
@@ -601,8 +595,7 @@ func TestHasManyAssociationUnscoped(t *testing.T) {
601595}
602596
603597func TestHasManyAssociationReplaceWithNonValidValue (t * testing.T ) {
604- t .Skip ()
605- user := User {Name : "jinzhu" , Languages : []Language {{Name : "EN" }}}
598+ user := User {Name : "jinzhu" , Languages : []Language {{Code : "EN" , Name : "EN" }}}
606599
607600 if err := DB .Create (& user ).Error ; err != nil {
608601 t .Fatalf ("errors happened when create: %v" , err )
0 commit comments