@@ -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 ()
1620 return NewStaticStore (baseDir ), baseDir
1721}
1822
1923func TestGetBrickReadmeFromID (t * testing.T ) {
20-
21- store , baseDir := setupTestStore ()
24+ store , baseDir := setupTestStore (t )
2225 namespace , brickName , _ := parseBrickID (validBrickID )
2326 expectedReadmePath := filepath .Join (baseDir , "docs" , namespace , brickName , "README.md" )
2427 expectedContent , err := os .ReadFile (expectedReadmePath )
@@ -57,15 +60,10 @@ func TestGetBrickReadmeFromID(t *testing.T) {
5760
5861 for _ , tc := range testCases {
5962 t .Run (tc .name , func (t * testing.T ) {
60-
6163 content , err := store .GetBrickReadmeFromID (tc .brickID )
62-
6364 if tc .wantErr {
64-
6565 require .Error (t , err , "should have returned an error" )
66-
6766 if tc .wantErrIs != nil {
68-
6967 require .ErrorIs (t , err , tc .wantErrIs , "error type mismatch" )
7068 }
7169 if 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 )
8682 namespace , brickName , _ := parseBrickID (validBrickID )
87-
8883 expectedPathString := filepath .Join (baseDir , "compose" , namespace , brickName , "brick_compose.yaml" )
8984
9085 testCases := []struct {
@@ -112,7 +107,6 @@ func TestGetBrickComposeFilePathFromID(t *testing.T) {
112107 for _ , tc := range testCases {
113108 t .Run (tc .name , func (t * testing.T ) {
114109 path , err := store .GetBrickComposeFilePathFromID (tc .brickID )
115-
116110 if tc .wantErr {
117111 require .Error (t , err , "function was expected to return an error" )
118112 require .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 )
132125 const expectedEntryCount = 2
133126
134127 testCases := []struct {
@@ -169,7 +162,6 @@ func TestGetBrickCodeExamplesPathFromID(t *testing.T) {
169162 } else {
170163 require .NoError (t , err , "should not have returned an error" )
171164 }
172-
173165 if tc .wantNilList {
174166 require .Nil (t , pathList , "pathList should be nil" )
175167 } else {
0 commit comments