@@ -2,6 +2,7 @@ package sketch
22
33import (
44 "context"
5+ "fmt"
56 "testing"
67
78 "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
@@ -11,7 +12,6 @@ import (
1112func Test_SketchNameWrongPattern (t * testing.T ) {
1213 invalidNames := []string {
1314 "&" ,
14- "" ,
1515 ".hello" ,
1616 "_hello" ,
1717 "-hello" ,
@@ -24,11 +24,9 @@ func Test_SketchNameWrongPattern(t *testing.T) {
2424 SketchName : name ,
2525 SketchDir : t .TempDir (),
2626 })
27- require .NotNil (t , err )
2827
29- require .Error (t , err , `Can't create sketch: invalid sketch name "%s". Required pattern %s` ,
30- name ,
31- sketchNameValidationRegex )
28+ require .EqualError (t , err , fmt .Sprintf (`Can't create sketch: invalid sketch name "%s": the first character must be alphanumeric, the following ones can also contain "_", "-", and ".".` ,
29+ name ))
3230 }
3331}
3432
@@ -38,9 +36,8 @@ func Test_SketchNameEmpty(t *testing.T) {
3836 SketchName : emptyName ,
3937 SketchDir : t .TempDir (),
4038 })
41- require .NotNil (t , err )
4239
43- require .Error (t , err , `Can't create sketch: sketch name cannot be empty` )
40+ require .EqualError (t , err , `Can't create sketch: sketch name cannot be empty` )
4441}
4542
4643func Test_SketchNameTooLong (t * testing.T ) {
@@ -52,11 +49,10 @@ func Test_SketchNameTooLong(t *testing.T) {
5249 SketchName : string (tooLongName ),
5350 SketchDir : t .TempDir (),
5451 })
55- require .NotNil (t , err )
5652
57- require .Error (t , err , `Can't create sketch: sketch name too long (%d characters). Maximum allowed length is %d` ,
53+ require .EqualError (t , err , fmt . Sprintf ( `Can't create sketch: sketch name too long (%d characters). Maximum allowed length is %d` ,
5854 len (tooLongName ),
59- sketchNameMaxLength )
55+ sketchNameMaxLength ))
6056}
6157
6258func Test_SketchNameOk (t * testing.T ) {
0 commit comments