@@ -20,6 +20,7 @@ import (
20
20
"testing"
21
21
22
22
"github.com/arduino/arduino-cli/internal/go-configmap"
23
+ "github.com/stretchr/testify/assert"
23
24
"github.com/stretchr/testify/require"
24
25
"gopkg.in/yaml.v3"
25
26
)
@@ -79,10 +80,22 @@ func TestApplyEnvVars(t *testing.T) {
79
80
c .Set ("foo" , "bar" )
80
81
c .Set ("fooz.bar" , "baz" )
81
82
c .Set ("answer" , 42 )
83
+ c .Set ("array" , []string {})
82
84
c .InjectEnvVars ([]string {"APP_FOO=app-bar" , "APP_FOOZ_BAR=app-baz" }, "APP" )
83
- require .Equal (t , "app-bar" , c .Get ("foo" ))
84
- require .Equal (t , "app-baz" , c .Get ("fooz.bar" ))
85
- require .Equal (t , 42 , c .Get ("answer" ))
85
+ assert .Equal (t , "app-bar" , c .Get ("foo" ))
86
+ assert .Equal (t , "app-baz" , c .Get ("fooz.bar" ))
87
+ assert .Equal (t , 42 , c .Get ("answer" ))
88
+
89
+ c .InjectEnvVars ([]string {"APP_ARRAY=element1 element2 element3" }, "APP" )
90
+ require .Equal (t , []string {"element1" , "element2" , "element3" }, c .GetStringSlice ("array" ))
91
+
92
+ // Test env containing array values with typed schema
93
+ {
94
+ m := configmap .New ()
95
+ m .SetKeyTypeSchema ("array" , []string {})
96
+ m .InjectEnvVars ([]string {"APP_ARRAY=e1 e2 e3" }, "APP" )
97
+ require .Equal (t , []string {"e1" , "e2" , "e3" }, m .GetStringSlice ("array" ))
98
+ }
86
99
}
87
100
88
101
func TestMerge (t * testing.T ) {
0 commit comments