@@ -65,18 +65,20 @@ func TestConfigSections(t *testing.T) {
65
65
},
66
66
}
67
67
for name , tt := range tests {
68
- t .Run (name , func (t * testing.T ) {
69
- assert := assert .New (t )
70
-
71
- err := tt .sections .validate ()
72
-
73
- if tt .wantErr {
74
- assert .NotNil (err )
75
- assert .Equal (tt .errMsg , err .Error ())
76
- } else {
77
- assert .Nil (err )
78
- }
79
- })
68
+ t .Run (
69
+ name , func (t * testing.T ) {
70
+ assert := assert .New (t )
71
+
72
+ err := tt .sections .validate ()
73
+
74
+ if tt .wantErr {
75
+ assert .NotNil (err )
76
+ assert .Equal (tt .errMsg , err .Error ())
77
+ } else {
78
+ assert .Nil (err )
79
+ }
80
+ },
81
+ )
80
82
}
81
83
}
82
84
@@ -142,12 +144,14 @@ func TestConfigVisibility(t *testing.T) {
142
144
},
143
145
}
144
146
for _ , tt := range tests {
145
- t .Run ("section visibility" , func (t * testing.T ) {
146
- assert := assert .New (t )
147
+ t .Run (
148
+ "section visibility" , func (t * testing.T ) {
149
+ assert := assert .New (t )
147
150
148
- visible := tt .sections .visibility (tt .name )
149
- assert .Equal (tt .expected , visible )
150
- })
151
+ visible := tt .sections .visibility (tt .name )
152
+ assert .Equal (tt .expected , visible )
153
+ },
154
+ )
151
155
}
152
156
}
153
157
@@ -184,6 +188,33 @@ func TestConfigOutput(t *testing.T) {
184
188
wantErr : false ,
185
189
errMsg : "" ,
186
190
},
191
+ "TemplateLiteralLineBreakLeadingWhitespace" : {
192
+ output : output {
193
+ File : "README.md" ,
194
+ Mode : OutputModeInject ,
195
+ Template : fmt .Sprintf (" %s\\ n%s\\ n%s" , OutputBeginComment , OutputContent , OutputEndComment ),
196
+ },
197
+ wantErr : false ,
198
+ errMsg : "" ,
199
+ },
200
+ "TemplateLiteralLineBreakTrailingWhitespace" : {
201
+ output : output {
202
+ File : "README.md" ,
203
+ Mode : OutputModeInject ,
204
+ Template : fmt .Sprintf ("%s\\ n%s\\ n%s " , OutputBeginComment , OutputContent , OutputEndComment ),
205
+ },
206
+ wantErr : false ,
207
+ errMsg : "" ,
208
+ },
209
+ "TemplateLiteralLineBreakLeadingAndTrailingWhitespace" : {
210
+ output : output {
211
+ File : "README.md" ,
212
+ Mode : OutputModeInject ,
213
+ Template : fmt .Sprintf (" %s\\ n%s\\ n%s " , OutputBeginComment , OutputContent , OutputEndComment ),
214
+ },
215
+ wantErr : false ,
216
+ errMsg : "" ,
217
+ },
187
218
"NoExtraValidationModeReplace" : {
188
219
output : output {
189
220
File : "README.md" ,
@@ -250,18 +281,20 @@ func TestConfigOutput(t *testing.T) {
250
281
},
251
282
}
252
283
for name , tt := range tests {
253
- t .Run (name , func (t * testing.T ) {
254
- assert := assert .New (t )
255
-
256
- err := tt .output .validate ()
257
-
258
- if tt .wantErr {
259
- assert .NotNil (err )
260
- assert .Equal (tt .errMsg , err .Error ())
261
- } else {
262
- assert .Nil (err )
263
- }
264
- })
284
+ t .Run (
285
+ name , func (t * testing.T ) {
286
+ assert := assert .New (t )
287
+
288
+ err := tt .output .validate ()
289
+
290
+ if tt .wantErr {
291
+ assert .NotNil (err )
292
+ assert .Equal (tt .errMsg , err .Error ())
293
+ } else {
294
+ assert .Nil (err )
295
+ }
296
+ },
297
+ )
265
298
}
266
299
}
267
300
@@ -434,12 +467,14 @@ func TestIsInlineComment(t *testing.T) {
434
467
},
435
468
}
436
469
for _ , tt := range tests {
437
- t .Run (tt .name , func (t * testing.T ) {
438
- assert := assert .New (t )
470
+ t .Run (
471
+ tt .name , func (t * testing.T ) {
472
+ assert := assert .New (t )
439
473
440
- actual := isInlineComment (tt .line )
441
- assert .Equal (tt .expected , actual )
442
- })
474
+ actual := isInlineComment (tt .line )
475
+ assert .Equal (tt .expected , actual )
476
+ },
477
+ )
443
478
}
444
479
}
445
480
@@ -480,18 +515,20 @@ func TestConfigSort(t *testing.T) {
480
515
},
481
516
}
482
517
for name , tt := range tests {
483
- t .Run (name , func (t * testing.T ) {
484
- assert := assert .New (t )
485
-
486
- err := tt .sort .validate ()
487
-
488
- if tt .wantErr {
489
- assert .NotNil (err )
490
- assert .Equal (tt .errMsg , err .Error ())
491
- } else {
492
- assert .Nil (err )
493
- }
494
- })
518
+ t .Run (
519
+ name , func (t * testing.T ) {
520
+ assert := assert .New (t )
521
+
522
+ err := tt .sort .validate ()
523
+
524
+ if tt .wantErr {
525
+ assert .NotNil (err )
526
+ assert .Equal (tt .errMsg , err .Error ())
527
+ } else {
528
+ assert .Nil (err )
529
+ }
530
+ },
531
+ )
495
532
}
496
533
}
497
534
@@ -526,18 +563,20 @@ func TestConfigOutputvalues(t *testing.T) {
526
563
},
527
564
}
528
565
for name , tt := range tests {
529
- t .Run (name , func (t * testing.T ) {
530
- assert := assert .New (t )
531
-
532
- err := tt .outputvalues .validate ()
533
-
534
- if tt .wantErr {
535
- assert .NotNil (err )
536
- assert .Equal (tt .errMsg , err .Error ())
537
- } else {
538
- assert .Nil (err )
539
- }
540
- })
566
+ t .Run (
567
+ name , func (t * testing.T ) {
568
+ assert := assert .New (t )
569
+
570
+ err := tt .outputvalues .validate ()
571
+
572
+ if tt .wantErr {
573
+ assert .NotNil (err )
574
+ assert .Equal (tt .errMsg , err .Error ())
575
+ } else {
576
+ assert .Nil (err )
577
+ }
578
+ },
579
+ )
541
580
}
542
581
}
543
582
@@ -593,20 +632,22 @@ func TestConfigValidate(t *testing.T) {
593
632
},
594
633
}
595
634
for name , tt := range tests {
596
- t .Run (name , func (t * testing.T ) {
597
- assert := assert .New (t )
598
-
599
- config := DefaultConfig ()
600
- config .Formatter = "foo"
601
- tt .config (config )
602
- err := config .Validate ()
603
-
604
- if tt .wantErr {
605
- assert .NotNil (err )
606
- assert .Equal (tt .errMsg , err .Error ())
607
- } else {
608
- assert .Nil (err )
609
- }
610
- })
635
+ t .Run (
636
+ name , func (t * testing.T ) {
637
+ assert := assert .New (t )
638
+
639
+ config := DefaultConfig ()
640
+ config .Formatter = "foo"
641
+ tt .config (config )
642
+ err := config .Validate ()
643
+
644
+ if tt .wantErr {
645
+ assert .NotNil (err )
646
+ assert .Equal (tt .errMsg , err .Error ())
647
+ } else {
648
+ assert .Nil (err )
649
+ }
650
+ },
651
+ )
611
652
}
612
653
}
0 commit comments