@@ -36,11 +36,11 @@ func TestRequireTableComment(t *testing.T) {
36
36
AllOrNothing : tt .allOrNothing ,
37
37
Exclude : tt .exclude ,
38
38
}
39
- s := newTestSchema ()
39
+ s := newTestSchema (t )
40
40
if warns := r .Check (s , tt .lintExclude ); len (warns ) != tt .want {
41
41
t .Errorf ("TestRequireTableComment(%d): got %v\n want %v" , i , len (warns ), tt .want )
42
42
}
43
- ns := newTestNoCommentSchema ()
43
+ ns := newTestNoCommentSchema (t )
44
44
if warns := r .Check (ns , tt .lintExclude ); len (warns ) != tt .wantNoComment {
45
45
t .Errorf ("TestRequireTableComment(%d) (no comment schema): got %v\n want %v" , i , len (warns ), tt .wantNoComment )
46
46
}
@@ -85,12 +85,12 @@ func TestRequireColumnComment(t *testing.T) {
85
85
Exclude : tt .exclude ,
86
86
ExcludeTables : tt .excludeTables ,
87
87
}
88
- s := newTestSchema ()
88
+ s := newTestSchema (t )
89
89
if warns := r .Check (s , tt .lintExclude ); len (warns ) != tt .want {
90
90
t .Errorf ("TestRequireColumnComment(%d): got %v\n want %v" , i , len (warns ), tt .want )
91
91
}
92
92
93
- ns := newTestNoCommentSchema ()
93
+ ns := newTestNoCommentSchema (t )
94
94
if warns := r .Check (ns , tt .lintExclude ); len (warns ) != tt .wantNoComment {
95
95
t .Errorf ("TestRequireColumnComment(%d) (no comment schema): got %v\n want %v" , i , len (warns ), tt .wantNoComment )
96
96
}
@@ -129,12 +129,12 @@ func TestRequireIndexComment(t *testing.T) {
129
129
Exclude : tt .exclude ,
130
130
ExcludeTables : tt .excludeTables ,
131
131
}
132
- s := newTestSchema ()
132
+ s := newTestSchema (t )
133
133
if warns := r .Check (s , tt .lintExclude ); len (warns ) != tt .want {
134
134
t .Errorf ("TestRequireIndexComment(%d): got %v\n want %v" , i , len (warns ), tt .want )
135
135
}
136
136
137
- ns := newTestNoCommentSchema ()
137
+ ns := newTestNoCommentSchema (t )
138
138
if warns := r .Check (ns , tt .lintExclude ); len (warns ) != tt .wantNoComment {
139
139
t .Errorf ("TestRequireIndexComment(%d) (no comment schema): got %v\n want %v" , i , len (warns ), tt .wantNoComment )
140
140
}
@@ -173,12 +173,12 @@ func TestRequireConstraintComment(t *testing.T) {
173
173
Exclude : tt .exclude ,
174
174
ExcludeTables : tt .excludeTables ,
175
175
}
176
- s := newTestSchema ()
176
+ s := newTestSchema (t )
177
177
if warns := r .Check (s , tt .lintExclude ); len (warns ) != tt .want {
178
178
t .Errorf ("TestRequireConstraintComment(%d): got %v\n want %v" , i , len (warns ), tt .want )
179
179
}
180
180
181
- ns := newTestNoCommentSchema ()
181
+ ns := newTestNoCommentSchema (t )
182
182
if warns := r .Check (ns , tt .lintExclude ); len (warns ) != tt .wantNoComment {
183
183
t .Errorf ("TestRequireConstraintComment(%d) (no comment schema): got %v\n want %v" , i , len (warns ), tt .wantNoComment )
184
184
}
@@ -217,12 +217,12 @@ func TestRequireTriggerComment(t *testing.T) {
217
217
Exclude : tt .exclude ,
218
218
ExcludeTables : tt .excludeTables ,
219
219
}
220
- s := newTestSchema ()
220
+ s := newTestSchema (t )
221
221
if warns := r .Check (s , tt .lintExclude ); len (warns ) != tt .want {
222
222
t .Errorf ("TestRequireTriggerComment(%d): got %v\n want %v" , i , len (warns ), tt .want )
223
223
}
224
224
225
- ns := newTestNoCommentSchema ()
225
+ ns := newTestNoCommentSchema (t )
226
226
if warns := r .Check (ns , tt .lintExclude ); len (warns ) != tt .wantNoComment {
227
227
t .Errorf ("TestRequireTriggerComment(%d) (no comment schema): got %v\n want %v" , i , len (warns ), tt .wantNoComment )
228
228
}
@@ -262,7 +262,7 @@ func TestUnrelatedTable(t *testing.T) {
262
262
AllOrNothing : tt .allOrNothing ,
263
263
Exclude : tt .exclude ,
264
264
}
265
- s := newTestSchema ()
265
+ s := newTestSchema (t )
266
266
warns := r .Check (s , tt .lintExclude )
267
267
if len (warns ) != tt .want {
268
268
t .Errorf ("TestUnrelatedTable(%d): got %v\n want %v" , i , len (warns ), tt .want )
@@ -272,7 +272,7 @@ func TestUnrelatedTable(t *testing.T) {
272
272
t .Errorf ("TestUnrelatedTable(%d): got %v\n want %v" , i , warns [0 ].Message , tt .wantMsg )
273
273
}
274
274
}
275
- ns := newTestNoRelationSchema ()
275
+ ns := newTestNoRelationSchema (t )
276
276
if warns := r .Check (ns , tt .lintExclude ); len (warns ) != tt .wantNoRelation {
277
277
fmt .Printf ("%v\n " , warns )
278
278
t .Errorf ("TestUnrelatedTable(%d) (no relation): got %v\n want %v" , i , len (warns ), tt .wantNoRelation )
@@ -301,7 +301,7 @@ func TestColumnCount(t *testing.T) {
301
301
Exclude : tt .exclude ,
302
302
Max : 3 ,
303
303
}
304
- s := newTestSchema ()
304
+ s := newTestSchema (t )
305
305
warns := r .Check (s , tt .lintExclude )
306
306
if len (warns ) != tt .want {
307
307
t .Errorf ("TestColumnCount(%d): got %v\n want %v" , i , len (warns ), tt .want )
@@ -339,7 +339,7 @@ func TestRequireColumns(t *testing.T) {
339
339
},
340
340
},
341
341
}
342
- s := newTestSchema ()
342
+ s := newTestSchema (t )
343
343
warns := r .Check (s , tt .lintExclude )
344
344
if len (warns ) != tt .want {
345
345
t .Errorf ("TestRequireColumns(%d): got %v\n want %v" , i , len (warns ), tt .want )
@@ -363,7 +363,7 @@ func TestDuplicateRelations(t *testing.T) {
363
363
r := DuplicateRelations {
364
364
Enabled : tt .enabled ,
365
365
}
366
- s := newTestSchema ()
366
+ s := newTestSchema (t )
367
367
copy := * s .Relations [0 ]
368
368
copy .Def = "copy"
369
369
s .Relations = append (s .Relations , & copy )
@@ -401,7 +401,7 @@ func TestRequireForeignKeyIndex(t *testing.T) {
401
401
Enabled : tt .enabled ,
402
402
Exclude : tt .exclude ,
403
403
}
404
- s := newTestSchema ()
404
+ s := newTestSchema (t )
405
405
warns := r .Check (s , tt .lintExclude )
406
406
if len (warns ) != tt .want {
407
407
t .Errorf ("TestRequireForeignKeyIndex(%d): got %v\n want %v" , i , len (warns ), tt .want )
@@ -423,7 +423,7 @@ func TestLabelStyleBigQuery(t *testing.T) {
423
423
r := LabelStyleBigQuery {
424
424
Enabled : tt .enabled ,
425
425
}
426
- s := newTestSchema ()
426
+ s := newTestSchema (t )
427
427
warns := r .Check (s , tt .lintExclude )
428
428
if len (warns ) != tt .want {
429
429
t .Errorf ("TestLabelStyleBigQuery(%d): got %v\n want %v" , i , len (warns ), tt .want )
@@ -461,7 +461,7 @@ func TestCheckLabelStyleBigQuery(t *testing.T) {
461
461
}
462
462
}
463
463
464
- func newTestSchema () * schema.Schema {
464
+ func newTestSchema (t * testing. T ) * schema.Schema {
465
465
ca := & schema.Column {
466
466
Name : "column_a1" ,
467
467
Type : "bigint(20)" ,
@@ -615,8 +615,9 @@ func newTestSchema() *schema.Schema {
615
615
return s
616
616
}
617
617
618
- func newTestNoCommentSchema () * schema.Schema {
619
- s := newTestSchema ()
618
+ func newTestNoCommentSchema (t * testing.T ) * schema.Schema {
619
+ t .Helper ()
620
+ s := newTestSchema (t )
620
621
for _ , t := range s .Tables {
621
622
t .Comment = ""
622
623
for _ , c := range t .Columns {
@@ -635,8 +636,9 @@ func newTestNoCommentSchema() *schema.Schema {
635
636
return s
636
637
}
637
638
638
- func newTestNoRelationSchema () * schema.Schema {
639
- s := newTestSchema ()
639
+ func newTestNoRelationSchema (t * testing.T ) * schema.Schema {
640
+ t .Helper ()
641
+ s := newTestSchema (t )
640
642
for _ , t := range s .Tables {
641
643
for _ , c := range t .Columns {
642
644
c .ChildRelations = nil
0 commit comments