@@ -2,6 +2,7 @@ package sketch
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
"testing"
6
7
7
8
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
@@ -11,7 +12,6 @@ import (
11
12
func Test_SketchNameWrongPattern (t * testing.T ) {
12
13
invalidNames := []string {
13
14
"&" ,
14
- "" ,
15
15
".hello" ,
16
16
"_hello" ,
17
17
"-hello" ,
@@ -24,11 +24,9 @@ func Test_SketchNameWrongPattern(t *testing.T) {
24
24
SketchName : name ,
25
25
SketchDir : t .TempDir (),
26
26
})
27
- require .NotNil (t , err )
28
27
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 ))
32
30
}
33
31
}
34
32
@@ -38,9 +36,8 @@ func Test_SketchNameEmpty(t *testing.T) {
38
36
SketchName : emptyName ,
39
37
SketchDir : t .TempDir (),
40
38
})
41
- require .NotNil (t , err )
42
39
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` )
44
41
}
45
42
46
43
func Test_SketchNameTooLong (t * testing.T ) {
@@ -52,11 +49,10 @@ func Test_SketchNameTooLong(t *testing.T) {
52
49
SketchName : string (tooLongName ),
53
50
SketchDir : t .TempDir (),
54
51
})
55
- require .NotNil (t , err )
56
52
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` ,
58
54
len (tooLongName ),
59
- sketchNameMaxLength )
55
+ sketchNameMaxLength ))
60
56
}
61
57
62
58
func Test_SketchNameOk (t * testing.T ) {
0 commit comments