Vehicle: test feature param consistency for shared include (#31321)

This commit is contained in:
andig 2026-06-29 11:35:28 +02:00 • committed by GitHub
parent bfc97db357
commit cdb2914308
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package vehicle
import (
"strings"
"testing"
"github.com/evcc-io/evcc/api"
@ -40,3 +41,25 @@ func TestTemplates(t *testing.T) {
}
})
}
// universalVehicleFeatures render via the shared vehicle-features include, so a
// stored config may carry them; dropping the param breaks reload (discussion #31291).
var universalVehicleFeatures = []string{"climaterdisabled", "autodetectdisabled"}
func TestVehicleFeatureParamsConsistent(t *testing.T) {
for _, tmpl := range templates.ByClass(templates.Vehicle, templates.WithDeprecated()) {
if !strings.Contains(tmpl.Render, "vehicle-features") {
continue
}
for _, feat := range universalVehicleFeatures {
values := tmpl.Defaults(templates.RenderModeUnitTest)
values["template"] = tmpl.Template
values[feat] = true
if _, _, err := tmpl.RenderResult(templates.RenderModeInstance, values); err != nil {
t.Errorf("%s: feature %q must stay a declared param: %v", tmpl.Template, feat, err)
}
}
}
}