@@ -313,6 +313,20 @@ func TestGetBrickInstanceVariableDetails(t *testing.T) {
313313 expectedConfigVariables : []BrickConfigVariable {},
314314 expectedVariableMap : map [string ]string {},
315315 },
316+ {
317+ name : "hidden variables" ,
318+ brick : & bricksindex.Brick {Variables : []bricksindex.BrickVariable {
319+ {Name : "HIDDEN_VAR" , DefaultValue : "i-am-hidden" , Description : "a-hidden-variable" , Hidden : true },
320+ {Name : "VISIBLE_VAR" , DefaultValue : "i-am-visible" , Description : "a-visible-variable" , Hidden : false },
321+ {Name : "VISIBLE_VAR_WITH_MISSING" , DefaultValue : "i-am-visible-if-missing-hidden" , Description : "a-visible-variable" },
322+ }},
323+ userVariables : map [string ]string {},
324+ expectedConfigVariables : []BrickConfigVariable {
325+ {Name : "VISIBLE_VAR" , Value : "i-am-visible" , Description : "a-visible-variable" , Required : true },
326+ {Name : "VISIBLE_VAR_WITH_MISSING" , Value : "i-am-visible-if-missing-hidden" , Description : "a-visible-variable" , Required : true },
327+ },
328+ expectedVariableMap : map [string ]string {"VISIBLE_VAR" : "i-am-visible" , "VISIBLE_VAR_WITH_MISSING" : "i-am-visible-if-missing-hidden" },
329+ },
316330 }
317331
318332 for _ , tt := range tests {
@@ -705,6 +719,15 @@ func TestAppBrickInstancesList(t *testing.T) {
705719 RequireModel : false ,
706720 Ports : []string {"7000" , "8000" },
707721 },
722+ {
723+ ID : "arduino:with-hidden-vars" ,
724+ Name : "I have some hidden variables" ,
725+ Variables : []bricksindex.BrickVariable {
726+ {Name : "HIDDEN_VAR" , DefaultValue : "/i/am/hidden" , Hidden : true },
727+ {Name : "VISIBLE_VAR" , DefaultValue : "/i/am/visible" },
728+ {Name : "VISIBLE_VAR_IF_MISSING" , DefaultValue : "/i/am/visible" , Hidden : false },
729+ },
730+ },
708731 },
709732 }
710733
@@ -833,6 +856,32 @@ func TestAppBrickInstancesList(t *testing.T) {
833856 require .Equal (t , "/models/ootb/ei/glass-breaking.eim" , b2 .ConfigVariables [1 ].Value )
834857 },
835858 },
859+ {
860+ name : "Success - hidden variables are not included" ,
861+ app : & app.ArduinoApp {
862+ Descriptor : app.AppDescriptor {
863+ Bricks : []app.Brick {
864+ {
865+ ID : "arduino:with-hidden-vars" ,
866+ Variables : map [string ]string {
867+ "HIDDEN_VAR" : "/this/is/a/new/hidden/value" ,
868+ "VISIBLE_VAR" : "/this/isa/new/visible/value" ,
869+ },
870+ },
871+ },
872+ },
873+ },
874+ validate : func (t * testing.T , res AppBrickInstancesResult ) {
875+ require .Len (t , res .BrickInstances , 1 )
876+ brick := res .BrickInstances [0 ]
877+ require .Equal (t , "arduino:with-hidden-vars" , brick .ID )
878+ want := []BrickConfigVariable {
879+ {Name : "VISIBLE_VAR" , Value : "/this/is/a/new/visible/value" },
880+ {Name : "VISIBLE_VAR_IF_MISSING" , Value : "/i/am/visible" },
881+ }
882+ require .Equal (t , want , brick .ConfigVariables )
883+ },
884+ },
836885 }
837886
838887 for _ , tt := range tests {
0 commit comments