@@ -7,18 +7,21 @@ import (
77
88"github.com/arduino/go-paths-helper"
99"github.com/stretchr/testify/require"
10+
11+ "github.com/arduino/arduino-app-cli/internal/orchestrator/config"
1012)
1113
1214const validBrickID = "arduino:arduino_cloud"
1315
14- func setupTestStore () (* StaticStore ,string ) {
15- baseDir := paths .New ("testdata" ).String ()
16+ func setupTestStore (t * testing.T ) (* StaticStore ,string ) {
17+ cfg ,err := config .NewFromEnv ()
18+ require .NoError (t ,err )
19+ baseDir := paths .New ("testdata" ,"assets" ,cfg .RunnerVersion ).String ()
1620return NewStaticStore (baseDir ),baseDir
1721}
1822
1923func TestGetBrickReadmeFromID (t * testing.T ) {
20-
21- store ,baseDir := setupTestStore ()
24+ store ,baseDir := setupTestStore (t )
2225namespace ,brickName ,_ := parseBrickID (validBrickID )
2326expectedReadmePath := filepath .Join (baseDir ,"docs" ,namespace ,brickName ,"README.md" )
2427expectedContent ,err := os .ReadFile (expectedReadmePath )
@@ -57,15 +60,10 @@ func TestGetBrickReadmeFromID(t *testing.T) {
5760
5861for _ ,tc := range testCases {
5962t .Run (tc .name ,func (t * testing.T ) {
60-
6163content ,err := store .GetBrickReadmeFromID (tc .brickID )
62-
6364if tc .wantErr {
64-
6565require .Error (t ,err ,"should have returned an error" )
66-
6766if tc .wantErrIs != nil {
68-
6967require .ErrorIs (t ,err ,tc .wantErrIs ,"error type mismatch" )
7068}
7169if tc .wantErrMsg != "" {
@@ -80,11 +78,8 @@ func TestGetBrickReadmeFromID(t *testing.T) {
8078}
8179
8280func TestGetBrickComposeFilePathFromID (t * testing.T ) {
83-
84- store ,baseDir := setupTestStore ()
85-
81+ store ,baseDir := setupTestStore (t )
8682namespace ,brickName ,_ := parseBrickID (validBrickID )
87-
8883expectedPathString := filepath .Join (baseDir ,"compose" ,namespace ,brickName ,"brick_compose.yaml" )
8984
9085testCases := []struct {
@@ -112,7 +107,6 @@ func TestGetBrickComposeFilePathFromID(t *testing.T) {
112107for _ ,tc := range testCases {
113108t .Run (tc .name ,func (t * testing.T ) {
114109path ,err := store .GetBrickComposeFilePathFromID (tc .brickID )
115-
116110if tc .wantErr {
117111require .Error (t ,err ,"function was expected to return an error" )
118112require .Nil (t ,path ,"path was expected to be nil" )
@@ -127,8 +121,7 @@ func TestGetBrickComposeFilePathFromID(t *testing.T) {
127121}
128122
129123func TestGetBrickCodeExamplesPathFromID (t * testing.T ) {
130- store ,_ := setupTestStore ()
131-
124+ store ,_ := setupTestStore (t )
132125const expectedEntryCount = 2
133126
134127testCases := []struct {
@@ -169,7 +162,6 @@ func TestGetBrickCodeExamplesPathFromID(t *testing.T) {
169162}else {
170163require .NoError (t ,err ,"should not have returned an error" )
171164}
172-
173165if tc .wantNilList {
174166require .Nil (t ,pathList ,"pathList should be nil" )
175167}else {