@@ -200,3 +200,43 @@ func TestBricksList(t *testing.T) {
200200 require .Equal (t , "/models/ootb/ei/mobilenet-v2-224px.eim" , b_ic .Variables [1 ].DefaultValue )
201201 require .Equal (t , "path to the model file" , b_ic .Variables [1 ].Description )
202202}
203+
204+ func TestAppBrickInstanceDetails (t * testing.T ) {
205+ bricksIndex , err := bricksindex .GenerateBricksIndexFromFile (paths .New ("testdata" ))
206+ require .Nil (t , err )
207+ brickService := NewService (nil , bricksIndex , nil )
208+ tempDirectory := t .TempDir ()
209+
210+ app := app.ArduinoApp {
211+ Name : "TestApp" ,
212+ Descriptor : app.AppDescriptor {
213+ Bricks : []app.Brick {
214+ {
215+ ID : "arduino:image_classification" ,
216+ },
217+ },
218+ },
219+ FullPath : paths .New (tempDirectory ),
220+ }
221+ configVariables , _ := brickService .AppBrickInstanceDetails (& app , bricksIndex .Bricks [2 ].ID )
222+
223+ expectedConfigVariables := BrickInstance {
224+ Name : "Image Classification" ,
225+ ID : "arduino:image_classification" ,
226+ Author : "Arduino" ,
227+ Category : "video" ,
228+ Status : "installed" ,
229+ Variables : map [string ]string {
230+ "CUSTOM_MODEL_PATH" : "/home/arduino/.arduino-bricks/ei-models" ,
231+ "EI_CLASSIFICATION_MODEL" : "/models/ootb/ei/mobilenet-v2-224px.eim" ,
232+ },
233+ ConfigVariables : []BrickConfigVariable {
234+ {Name : "CUSTOM_MODEL_PATH" , Value : "/home/arduino/.arduino-bricks/ei-models" , Description : "path to the custom model directory" , Required : false },
235+ {Name : "EI_CLASSIFICATION_MODEL" , Value : "/models/ootb/ei/mobilenet-v2-224px.eim" , Description : "path to the model file" , Required : false },
236+ },
237+ RequireModel : true ,
238+ ModelID : "mobilenet-image-classification" ,
239+ }
240+
241+ require .Equal (t , expectedConfigVariables , configVariables )
242+ }
0 commit comments