@@ -45,31 +45,28 @@ func TestGenerateModelsIndexFromFile(t *testing.T) {
4545 assert .Nil (t , modelsIndex )
4646 })
4747
48- t .Run ("it gets models by a single brick" , func (t * testing.T ) {
49- brick1Models := modelsIndex .GetModelsByBrick ("arduino:object_detection" )
50- assert .Len (t , brick1Models , 1 )
51- assert .Equal (t , "face-detection" , brick1Models [0 ].ID )
48+ t .Run ("it gets models by a brick" , func (t * testing.T ) {
49+ model := modelsIndex .GetModelsByBrick ("not-existing-brick" )
50+ assert .Nil (t , model )
5251
53- brick1Models = modelsIndex .GetModelsByBrick ("not-existing-brick" )
54- assert .Nil (t , brick1Models )
52+ model = modelsIndex .GetModelsByBrick ("arduino:object_detection" )
53+ assert .Len (t , model , 1 )
54+ assert .Equal (t , "face-detection" , model [0 ].ID )
5555 })
5656
57- t .Run ("it gets models by multiple bricks" , func (t * testing.T ) {
58- brick2Models := modelsIndex .GetModelsByBrick ("arduino:non_existing" )
59- assert .Len (t , brick2Models , 0 )
60- assert .Nil (t , brick2Models )
61-
62- brick2Models = modelsIndex .GetModelsByBrick ("arduino:video_object_detection" )
63- assert .Len (t , brick2Models , 2 )
64- assert .Equal (t , "face-detection" , brick2Models [0 ].ID )
65- assert .Equal (t , "yolox-object-detection" , brick2Models [1 ].ID )
57+ t .Run ("it gets models by bricks" , func (t * testing.T ) {
58+ models := modelsIndex .GetModelsByBricks ([]string {"arduino:non_existing" })
59+ assert .Len (t , models , 0 )
60+ assert .Nil (t , models )
6661
67- bricks2Models : = modelsIndex .GetModelsByBricks ([]string {"arduino:object_detection" , "arduino:video_object_detection" })
68- assert .Len (t , bricks2Models , 2 )
69- assert .Equal (t , "face-detection" , bricks2Models [0 ].ID )
70- assert .Equal (t , "yolox-object-detection" , bricks2Models [1 ].ID )
62+ models = modelsIndex .GetModelsByBricks ([]string {"arduino:video_object_detection" })
63+ assert .Len (t , models , 2 )
64+ assert .Equal (t , "face-detection" , models [0 ].ID )
65+ assert .Equal (t , "yolox-object-detection" , models [1 ].ID )
7166
72- nonExistentModels := modelsIndex .GetModelsByBrick ("nonexistent_brick" )
73- assert .Nil (t , nonExistentModels )
67+ models = modelsIndex .GetModelsByBricks ([]string {"arduino:object_detection" , "arduino:video_object_detection" })
68+ assert .Len (t , models , 2 )
69+ assert .Equal (t , "face-detection" , models [0 ].ID )
70+ assert .Equal (t , "yolox-object-detection" , models [1 ].ID )
7471 })
7572}
0 commit comments