42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package vehicle
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/evcc-io/evcc/api"
|
|
"github.com/evcc-io/evcc/util/templates"
|
|
"github.com/evcc-io/evcc/util/test"
|
|
)
|
|
|
|
var acceptable = []string{
|
|
api.ErrMissingCredentials.Error(),
|
|
api.ErrMissingToken.Error(),
|
|
"missing client id",
|
|
"invalid plugin source: ...",
|
|
"missing mqtt broker configuration",
|
|
"received status code 404 (INVALID PARAMS)", // Nissan
|
|
"missing personID",
|
|
"401 Unauthorized",
|
|
"unexpected length",
|
|
"i/o timeout",
|
|
"no such host",
|
|
"network is unreachable",
|
|
"error connecting: Network Error",
|
|
"unexpected status: 401",
|
|
"discussions/17501", // Tesla
|
|
"login failed: code not found", // Polestar
|
|
"login failed", // drivesomethinggreater (EU Data Act, eager login)
|
|
"empty instance type- check for missing usage", // Mercedes
|
|
"connect: connection refused", // MQTT
|
|
}
|
|
|
|
func TestTemplates(t *testing.T) {
|
|
templates.TestClass(t, templates.Vehicle, func(t *testing.T, values map[string]any) {
|
|
t.Helper()
|
|
|
|
if _, err := NewFromConfig(t.Context(), "template", values); err != nil && !test.Acceptable(err, acceptable) {
|
|
t.Log(values)
|
|
t.Error(err)
|
|
}
|
|
})
|
|
}
|