@@ -154,6 +154,37 @@ func TestBuilder_AddVars(t *testing.T) {
154154 }
155155 require .Len (t , o .Dashboard .Templating .List , 1 )
156156 })
157+
158+ t .Run ("AddVars adds variables with AllValue to the dashboard" , func (t * testing.T ) {
159+ builder := grafana .NewBuilder (& grafana.BuilderOptions {
160+ Name : "Dashboard Name" ,
161+ })
162+
163+ variable := grafana .NewQueryVariable (& grafana.QueryVariableOptions {
164+ VariableOption : & grafana.VariableOption {
165+ Name : "Variable Name" ,
166+ Label : "Variable Label" ,
167+ },
168+ Query : "query" ,
169+ Datasource : grafana .NewDataSource ("Prometheus" , "" ).Name ,
170+ IncludeAll : true ,
171+ AllValue : ".*" ,
172+ })
173+
174+ builder .AddVars (variable )
175+ o , err := builder .Build ()
176+ if err != nil {
177+ t .Errorf ("Error building dashboard: %v" , err )
178+ }
179+ require .Len (t , o .Dashboard .Templating .List , 1 )
180+
181+ // Verify the AllValue is set correctly
182+ varModel := o .Dashboard .Templating .List [0 ]
183+ require .NotNil (t , varModel .AllValue )
184+ require .Equal (t , ".*" , * varModel .AllValue )
185+ require .NotNil (t , varModel .IncludeAll )
186+ require .True (t , * varModel .IncludeAll )
187+ })
157188}
158189
159190func TestBuilder_AddRow (t * testing.T ) {
0 commit comments