@@ -24,8 +24,10 @@ func TestSubmitWithoutToken(t *testing.T) {
24
24
}
25
25
26
26
err := runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), []string {})
27
- assert .Regexp (t , "Welcome to Exercism" , err .Error ())
28
- assert .Regexp (t , "exercism.io/my/settings" , err .Error ())
27
+ if assert .Error (t , err ) {
28
+ assert .Regexp (t , "Welcome to Exercism" , err .Error ())
29
+ assert .Regexp (t , "exercism.io/my/settings" , err .Error ())
30
+ }
29
31
}
30
32
31
33
func TestSubmitWithoutWorkspace (t * testing.T ) {
@@ -39,7 +41,9 @@ func TestSubmitWithoutWorkspace(t *testing.T) {
39
41
}
40
42
41
43
err := runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), []string {})
42
- assert .Regexp (t , "re-run the configure" , err .Error ())
44
+ if assert .Error (t , err ) {
45
+ assert .Regexp (t , "re-run the configure" , err .Error ())
46
+ }
43
47
}
44
48
45
49
func TestSubmitNonExistentFile (t * testing.T ) {
@@ -68,7 +72,9 @@ func TestSubmitNonExistentFile(t *testing.T) {
68
72
filepath .Join (tmpDir , "file-2.txt" ),
69
73
}
70
74
err = runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), files )
71
- assert .Regexp (t , "cannot be found" , err .Error ())
75
+ if assert .Error (t , err ) {
76
+ assert .Regexp (t , "cannot be found" , err .Error ())
77
+ }
72
78
}
73
79
74
80
func TestSubmitExerciseWithoutMetadataFile (t * testing.T ) {
@@ -94,8 +100,9 @@ func TestSubmitExerciseWithoutMetadataFile(t *testing.T) {
94
100
}
95
101
96
102
err = runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), []string {file })
97
- assert .Error (t , err )
98
- assert .Regexp (t , "doesn't have the necessary metadata" , err .Error ())
103
+ if assert .Error (t , err ) {
104
+ assert .Regexp (t , "doesn't have the necessary metadata" , err .Error ())
105
+ }
99
106
}
100
107
101
108
func TestSubmitFilesAndDir (t * testing.T ) {
@@ -124,8 +131,10 @@ func TestSubmitFilesAndDir(t *testing.T) {
124
131
filepath .Join (tmpDir , "file-2.txt" ),
125
132
}
126
133
err = runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), files )
127
- assert .Regexp (t , "submitting a directory" , err .Error ())
128
- assert .Regexp (t , "Please change into the directory and provide the path to the file\\ (s\\ ) you wish to submit" , err .Error ())
134
+ if assert .Error (t , err ) {
135
+ assert .Regexp (t , "submitting a directory" , err .Error ())
136
+ assert .Regexp (t , "Please change into the directory and provide the path to the file\\ (s\\ ) you wish to submit" , err .Error ())
137
+ }
129
138
}
130
139
131
140
func TestSubmitFiles (t * testing.T ) {
@@ -339,8 +348,9 @@ func TestSubmitWithEnormousFile(t *testing.T) {
339
348
340
349
err = runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), []string {file })
341
350
342
- assert .Error (t , err )
343
- assert .Regexp (t , "Please reduce the size of the file and try again." , err .Error ())
351
+ if assert .Error (t , err ) {
352
+ assert .Regexp (t , "Please reduce the size of the file and try again." , err .Error ())
353
+ }
344
354
}
345
355
346
356
func TestSubmitFilesForTeamExercise (t * testing.T ) {
@@ -426,8 +436,9 @@ func TestSubmitOnlyEmptyFile(t *testing.T) {
426
436
err = ioutil .WriteFile (file , []byte ("" ), os .FileMode (0755 ))
427
437
428
438
err = runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), []string {file })
429
- assert .Error (t , err )
430
- assert .Regexp (t , "No files found" , err .Error ())
439
+ if assert .Error (t , err ) {
440
+ assert .Regexp (t , "No files found" , err .Error ())
441
+ }
431
442
}
432
443
433
444
func TestSubmitFilesFromDifferentSolutions (t * testing.T ) {
@@ -462,8 +473,9 @@ func TestSubmitFilesFromDifferentSolutions(t *testing.T) {
462
473
}
463
474
464
475
err = runSubmit (cfg , pflag .NewFlagSet ("fake" , pflag .PanicOnError ), []string {file1 , file2 })
465
- assert .Error (t , err )
466
- assert .Regexp (t , "different solutions" , err .Error ())
476
+ if assert .Error (t , err ) {
477
+ assert .Regexp (t , "different solutions" , err .Error ())
478
+ }
467
479
}
468
480
469
481
func fakeSubmitServer (t * testing.T , submittedFiles map [string ]string ) * httptest.Server {
0 commit comments