@@ -24,6 +24,8 @@ import (
24
24
"github.com/arduino/go-paths-helper"
25
25
"github.com/stretchr/testify/require"
26
26
"go.bug.st/testsuite"
27
+ "gopkg.in/src-d/go-git.v4"
28
+ "gopkg.in/src-d/go-git.v4/plumbing"
27
29
)
28
30
29
31
func TestBoardList (t * testing.T ) {
@@ -110,3 +112,51 @@ func TestBoardListall(t *testing.T) {
110
112
require .NotEmpty (t , platform ["latest" ])
111
113
require .Equal (t , platform ["name" ], "Arduino AVR Boards" )
112
114
}
115
+
116
+ func TestBoardListallWithManuallyInstalledPlatform (t * testing.T ) {
117
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
118
+ defer env .CleanUp ()
119
+
120
+ _ , _ , err := cli .Run ("update" )
121
+ require .NoError (t , err )
122
+
123
+ // Manually installs a core in sketchbooks hardware folder
124
+ gitUrl := "https://github.com/arduino/ArduinoCore-samd.git"
125
+ repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "samd" )
126
+ _ , err = git .PlainClone (repoDir .String (), false , & git.CloneOptions {
127
+ URL : gitUrl ,
128
+ ReferenceName : plumbing .NewTagReferenceName ("1.8.11" ),
129
+ })
130
+ require .NoError (t , err )
131
+
132
+ stdout , _ , err := cli .Run ("board" , "listall" , "--format" , "json" )
133
+ require .NoError (t , err )
134
+ var data map [string ]interface {}
135
+ err = json .Unmarshal (stdout , & data )
136
+ require .NoError (t , err )
137
+
138
+ // maps each json contained in "boards" using
139
+ // its corresponding "fqbn" value as its key
140
+ boards := make (map [string ]map [string ]interface {})
141
+ for _ , v := range data ["boards" ].([]interface {}) {
142
+ mapV := v .(map [string ]interface {})
143
+ boards [mapV ["fqbn" ].(string )] = mapV
144
+ }
145
+ require .Len (t , boards , 17 )
146
+
147
+ require .Contains (t , boards , "arduino-beta-development:samd:nano_33_iot" )
148
+ require .Equal (t , boards ["arduino-beta-development:samd:nano_33_iot" ]["name" ], "Arduino NANO 33 IoT" )
149
+ platform := boards ["arduino-beta-development:samd:nano_33_iot" ]["platform" ].(map [string ]interface {})
150
+ require .Equal (t , platform ["id" ], "arduino-beta-development:samd" )
151
+ require .Equal (t , platform ["installed" ], "1.8.11" )
152
+ require .Equal (t , platform ["latest" ], "1.8.11" )
153
+ require .Equal (t , platform ["name" ], "Arduino SAMD (32-bits ARM Cortex-M0+) Boards" )
154
+
155
+ require .Contains (t , boards , "arduino-beta-development:samd:mkr1000" )
156
+ require .Equal (t , boards ["arduino-beta-development:samd:mkr1000" ]["name" ], "Arduino MKR1000" )
157
+ platform = boards ["arduino-beta-development:samd:mkr1000" ]["platform" ].(map [string ]interface {})
158
+ require .Equal (t , platform ["id" ], "arduino-beta-development:samd" )
159
+ require .Equal (t , platform ["installed" ], "1.8.11" )
160
+ require .Equal (t , platform ["latest" ], "1.8.11" )
161
+ require .Equal (t , platform ["name" ], "Arduino SAMD (32-bits ARM Cortex-M0+) Boards" )
162
+ }
0 commit comments