@@ -9,19 +9,16 @@ import (
99)
1010
1111func TestGenerateModelsIndexFromFile (t * testing.T ) {
12- t .Run ("it parses a valid model-list.yaml" , func (t * testing.T ) {
13- modelsIndex , err := GenerateModelsIndexFromFile (paths .New ("testdata" ))
14- require .NoError (t , err )
15- require .NotNil (t , modelsIndex )
12+ modelsIndex , err := GenerateModelsIndexFromFile (paths .New ("testdata" ))
13+ require .NoError (t , err )
14+ require .NotNil (t , modelsIndex )
1615
16+ t .Run ("it parses a valid model-list.yaml" , func (t * testing.T ) {
1717 models := modelsIndex .GetModels ()
1818 assert .Len (t , models , 2 , "Expected 2 models to be parsed" )
1919 })
2020
2121 t .Run ("it gets a model by ID" , func (t * testing.T ) {
22- modelsIndex , err := GenerateModelsIndexFromFile (paths .New ("testdata" ))
23- require .NoError (t , err )
24-
2522 model , found := modelsIndex .GetModelByID ("not-existing-model" )
2623 assert .False (t , found )
2724 assert .Nil (t , model )
@@ -48,10 +45,7 @@ func TestGenerateModelsIndexFromFile(t *testing.T) {
4845 assert .Nil (t , modelsIndex )
4946 })
5047
51- t .Run ("it filters models by a single brick" , func (t * testing.T ) {
52- modelsIndex , err := GenerateModelsIndexFromFile (paths .New ("testdata" ))
53- require .NoError (t , err )
54-
48+ t .Run ("it gets models by a single brick" , func (t * testing.T ) {
5549 brick1Models := modelsIndex .GetModelsByBrick ("arduino:object_detection" )
5650 assert .Len (t , brick1Models , 1 )
5751 assert .Equal (t , "face-detection" , brick1Models [0 ].ID )
@@ -60,11 +54,12 @@ func TestGenerateModelsIndexFromFile(t *testing.T) {
6054 assert .Nil (t , brick1Models )
6155 })
6256
63- t .Run ("it filters models by multiple bricks" , func (t * testing.T ) {
64- modelsIndex , err := GenerateModelsIndexFromFile (paths .New ("testdata" ))
65- require .NoError (t , err )
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 )
6661
67- brick2Models : = modelsIndex .GetModelsByBrick ("arduino:video_object_detection" )
62+ brick2Models = modelsIndex .GetModelsByBrick ("arduino:video_object_detection" )
6863 assert .Len (t , brick2Models , 2 )
6964 assert .Equal (t , "face-detection" , brick2Models [0 ].ID )
7065 assert .Equal (t , "yolox-object-detection" , brick2Models [1 ].ID )
0 commit comments