@@ -47,35 +47,34 @@ import (
47
47
)
48
48
49
49
func TestHasManyAssociation (t * testing.T ) {
50
- t .Skip ()
51
50
user := * GetUser ("hasmany" , Config {Pets : 2 })
52
51
53
52
if err := DB .Create (& user ).Error ; err != nil {
54
53
t .Fatalf ("errors happened when create: %v" , err )
55
54
}
56
55
57
- CheckUser (t , user , user )
56
+ CheckUserSkipUpdatedAt (t , user , user )
58
57
59
58
// Find
60
59
var user2 User
61
- DB .Find (& user2 , "id = ?" , user .ID )
60
+ DB .Find (& user2 , "\" id \" = ?" , user .ID )
62
61
DB .Model (& user2 ).Association ("Pets" ).Find (& user2 .Pets )
63
- CheckUser (t , user2 , user )
62
+ CheckUserSkipUpdatedAt (t , user2 , user )
64
63
65
64
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 )
67
66
68
67
if len (pets ) != 1 {
69
68
t .Fatalf ("should only find one pets, but got %v" , len (pets ))
70
69
}
71
70
72
71
CheckPet (t , pets [0 ], * user .Pets [0 ])
73
72
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 {
75
74
t .Fatalf ("should only find one pets, but got %v" , count )
76
75
}
77
76
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 {
79
78
t .Fatalf ("should only find no pet with invalid conditions, but got %v" , count )
80
79
}
81
80
@@ -94,7 +93,7 @@ func TestHasManyAssociation(t *testing.T) {
94
93
}
95
94
96
95
user .Pets = append (user .Pets , & pet )
97
- CheckUser (t , user2 , user )
96
+ CheckUserSkipUpdatedAt (t , user2 , user )
98
97
99
98
AssertAssociationCount (t , user , "Pets" , 3 , "AfterAppend" )
100
99
@@ -113,7 +112,7 @@ func TestHasManyAssociation(t *testing.T) {
113
112
user .Pets = append (user .Pets , & pet )
114
113
}
115
114
116
- CheckUser (t , user2 , user )
115
+ CheckUserSkipUpdatedAt (t , user2 , user )
117
116
118
117
AssertAssociationCount (t , user , "Pets" , 5 , "AfterAppendSlice" )
119
118
@@ -129,7 +128,7 @@ func TestHasManyAssociation(t *testing.T) {
129
128
}
130
129
131
130
user .Pets = []* Pet {& pet2 }
132
- CheckUser (t , user2 , user )
131
+ CheckUserSkipUpdatedAt (t , user2 , user )
133
132
134
133
AssertAssociationCount (t , user2 , "Pets" , 1 , "AfterReplace" )
135
134
@@ -160,20 +159,19 @@ func TestHasManyAssociation(t *testing.T) {
160
159
}
161
160
162
161
func TestSingleTableHasManyAssociation (t * testing.T ) {
163
- t .Skip ()
164
162
user := * GetUser ("hasmany" , Config {Team : 2 })
165
163
166
164
if err := DB .Create (& user ).Error ; err != nil {
167
165
t .Fatalf ("errors happened when create: %v" , err )
168
166
}
169
167
170
- CheckUser (t , user , user )
168
+ CheckUserSkipUpdatedAt (t , user , user )
171
169
172
170
// Find
173
171
var user2 User
174
- DB .Find (& user2 , "id = ?" , user .ID )
172
+ DB .Find (& user2 , "\" id \" = ?" , user .ID )
175
173
DB .Model (& user2 ).Association ("Team" ).Find (& user2 .Team )
176
- CheckUser (t , user2 , user )
174
+ CheckUserSkipUpdatedAt (t , user2 , user )
177
175
178
176
// Count
179
177
AssertAssociationCount (t , user , "Team" , 2 , "" )
@@ -190,7 +188,7 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
190
188
}
191
189
192
190
user .Team = append (user .Team , team )
193
- CheckUser (t , user2 , user )
191
+ CheckUserSkipUpdatedAt (t , user2 , user )
194
192
195
193
AssertAssociationCount (t , user , "Team" , 3 , "AfterAppend" )
196
194
@@ -209,7 +207,7 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
209
207
user .Team = append (user .Team , team )
210
208
}
211
209
212
- CheckUser (t , user2 , user )
210
+ CheckUserSkipUpdatedAt (t , user2 , user )
213
211
214
212
AssertAssociationCount (t , user , "Team" , 5 , "AfterAppendSlice" )
215
213
@@ -225,7 +223,7 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
225
223
}
226
224
227
225
user .Team = []User {team2 }
228
- CheckUser (t , user2 , user )
226
+ CheckUserSkipUpdatedAt (t , user2 , user )
229
227
230
228
AssertAssociationCount (t , user2 , "Team" , 1 , "AfterReplace" )
231
229
@@ -256,7 +254,6 @@ func TestSingleTableHasManyAssociation(t *testing.T) {
256
254
}
257
255
258
256
func TestHasManyAssociationForSlice (t * testing.T ) {
259
- t .Skip ()
260
257
users := []User {
261
258
* GetUser ("slice-hasmany-1" , Config {Pets : 2 }),
262
259
* GetUser ("slice-hasmany-2" , Config {Pets : 0 }),
@@ -311,7 +308,6 @@ func TestHasManyAssociationForSlice(t *testing.T) {
311
308
}
312
309
313
310
func TestSingleTableHasManyAssociationForSlice (t * testing.T ) {
314
- t .Skip ()
315
311
users := []User {
316
312
* GetUser ("slice-hasmany-1" , Config {Team : 2 }),
317
313
* GetUser ("slice-hasmany-2" , Config {Team : 0 }),
@@ -368,20 +364,19 @@ func TestSingleTableHasManyAssociationForSlice(t *testing.T) {
368
364
}
369
365
370
366
func TestPolymorphicHasManyAssociation (t * testing.T ) {
371
- t .Skip ()
372
367
user := * GetUser ("hasmany" , Config {Toys : 2 })
373
368
374
369
if err := DB .Create (& user ).Error ; err != nil {
375
370
t .Fatalf ("errors happened when create: %v" , err )
376
371
}
377
372
378
- CheckUser (t , user , user )
373
+ CheckUserSkipUpdatedAt (t , user , user )
379
374
380
375
// Find
381
376
var user2 User
382
- DB .Find (& user2 , "id = ?" , user .ID )
377
+ DB .Find (& user2 , "\" id \" = ?" , user .ID )
383
378
DB .Model (& user2 ).Association ("Toys" ).Find (& user2 .Toys )
384
- CheckUser (t , user2 , user )
379
+ CheckUserSkipUpdatedAt (t , user2 , user )
385
380
386
381
// Count
387
382
AssertAssociationCount (t , user , "Toys" , 2 , "" )
@@ -398,7 +393,7 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
398
393
}
399
394
400
395
user .Toys = append (user .Toys , toy )
401
- CheckUser (t , user2 , user )
396
+ CheckUserSkipUpdatedAt (t , user2 , user )
402
397
403
398
AssertAssociationCount (t , user , "Toys" , 3 , "AfterAppend" )
404
399
@@ -417,7 +412,7 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
417
412
user .Toys = append (user .Toys , toy )
418
413
}
419
414
420
- CheckUser (t , user2 , user )
415
+ CheckUserSkipUpdatedAt (t , user2 , user )
421
416
422
417
AssertAssociationCount (t , user , "Toys" , 5 , "AfterAppendSlice" )
423
418
@@ -433,7 +428,7 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
433
428
}
434
429
435
430
user .Toys = []Toy {toy2 }
436
- CheckUser (t , user2 , user )
431
+ CheckUserSkipUpdatedAt (t , user2 , user )
437
432
438
433
AssertAssociationCount (t , user2 , "Toys" , 1 , "AfterReplace" )
439
434
@@ -464,7 +459,6 @@ func TestPolymorphicHasManyAssociation(t *testing.T) {
464
459
}
465
460
466
461
func TestPolymorphicHasManyAssociationForSlice (t * testing.T ) {
467
- t .Skip ()
468
462
users := []User {
469
463
* GetUser ("slice-hasmany-1" , Config {Toys : 2 }),
470
464
* GetUser ("slice-hasmany-2" , Config {Toys : 0 , Tools : 2 }),
@@ -601,8 +595,7 @@ func TestHasManyAssociationUnscoped(t *testing.T) {
601
595
}
602
596
603
597
func 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" }}}
606
599
607
600
if err := DB .Create (& user ).Error ; err != nil {
608
601
t .Fatalf ("errors happened when create: %v" , err )
0 commit comments