Remove dependency from config repo (#2182)

The templates infrastructure replaces this
This commit is contained in:
Andreas Linde 2022-01-01 17:50:32 +01:00 • committed by GitHub
parent 3b7f3824a5
commit fb1d6f552f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 179 deletions

View file

@ -1,45 +0,0 @@
package charger
import (
"testing"
"github.com/evcc-io/evcc/util/test"
)
var acceptable = []string{
"invalid plugin type: ...",
"missing mqtt broker configuration",
"mqtt not configured",
"invalid charger type: nrgkick-bluetooth",
"NRGKick bluetooth is only supported on linux",
"invalid pin:",
"hciconfig provided no response",
"connect: no route to host",
"connect: connection refused",
"error connecting: Network Error",
"i/o timeout",
"recv timeout",
"(Client.Timeout exceeded while awaiting headers)",
"can only have either uri or device", // modbus
"sponsorship required, see https://github.com/evcc-io/evcc#sponsorship",
"eebus not configured",
"unexpected status: 400", // easee
}
func TestConfigChargers(t *testing.T) {
test.SkipCI(t)
for _, tmpl := range test.ConfigTemplates("charger") {
tmpl := tmpl
t.Run(tmpl.Name, func(t *testing.T) {
t.Parallel()
_, err := NewFromConfig(tmpl.Type, tmpl.Config)
if err != nil && !test.Acceptable(err, acceptable) {
t.Logf("%s: %+v", tmpl.Name, tmpl.Config)
t.Error(err)
}
})
}
}

View file

@ -8,6 +8,26 @@ import (
"github.com/thoas/go-funk"
)
var acceptable = []string{
"invalid plugin type: ...",
"missing mqtt broker configuration",
"mqtt not configured",
"invalid charger type: nrgkick-bluetooth",
"NRGKick bluetooth is only supported on linux",
"invalid pin:",
"hciconfig provided no response",
"connect: no route to host",
"connect: connection refused",
"error connecting: Network Error",
"i/o timeout",
"recv timeout",
"(Client.Timeout exceeded while awaiting headers)",
"can only have either uri or device", // modbus
"sponsorship required, see https://github.com/evcc-io/evcc#sponsorship",
"eebus not configured",
"unexpected status: 400", // easee
}
func TestChargerTemplates(t *testing.T) {
test.SkipCI(t)

1
go.mod
View file

@ -23,7 +23,6 @@ require (
github.com/dustin/go-humanize v1.0.0
github.com/dylanmei/iso8601 v0.1.0
github.com/eclipse/paho.mqtt.golang v1.3.5
github.com/evcc-io/config v0.0.0-20211116174948-89807a2a9695
github.com/evcc-io/eebus v0.0.0-20211108130022-5536fd4b8fa1
github.com/fatih/structs v1.1.0
github.com/go-ping/ping v0.0.0-20211130115550-779d1e919534

2
go.sum
View file

@ -196,8 +196,6 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws=
github.com/evcc-io/config v0.0.0-20211116174948-89807a2a9695 h1:IaAbFjdRSnbRhuY1MRbrcXa2gVDYin6XuPdWAORR0ww=
github.com/evcc-io/config v0.0.0-20211116174948-89807a2a9695/go.mod h1:aN5D6PVnoFvfZSMScvAQAIYRXwWOZ9lde3J0lsNRIOM=
github.com/evcc-io/eebus v0.0.0-20211108130022-5536fd4b8fa1 h1:fEaXff1wN1s+ySvie/JZF1HeeZCofdGwd1jQeK45Ugw=
github.com/evcc-io/eebus v0.0.0-20211108130022-5536fd4b8fa1/go.mod h1:2fJZDu2dSe7M6m+KIYkG5XPdk+Ws1ckuRyklZRvFzWE=
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=

View file

@ -1,43 +0,0 @@
package meter
import (
"testing"
"github.com/evcc-io/evcc/util/test"
)
var acceptable = []string{
"invalid plugin type: ...",
"missing mqtt broker configuration",
"mqtt not configured",
"not a SunSpec device",
"missing password", // Powerwall
"connect: no route to host",
"connect: connection refused",
"i/o timeout",
"connect: network is unreachable",
"no ping response for 192.0.2.2", // SMA
"network is unreachable",
"[1ESY1161052714 1ESY1161229249 1EMH0008842285 1ESY1161978584 1EMH0004864048 1ESY1161979033 7ELS8135823805]", // Discovergy
"can only have either uri or device", // modbus
"(Client.Timeout exceeded while awaiting headers)", // http
"cannot create meter 'discovergy': unexpected status: 401", //Discovergy Proxy
}
func TestConfigMeters(t *testing.T) {
test.SkipCI(t)
for _, tmpl := range test.ConfigTemplates("meter") {
tmpl := tmpl
t.Run(tmpl.Name, func(t *testing.T) {
t.Parallel()
_, err := NewFromConfig(tmpl.Type, tmpl.Config)
if err != nil && !test.Acceptable(err, acceptable) {
t.Logf("%s: %+v", tmpl.Name, tmpl.Config)
t.Error(err)
}
})
}
}

View file

@ -8,6 +8,24 @@ import (
"github.com/thoas/go-funk"
)
var acceptable = []string{
"invalid plugin type: ...",
"missing mqtt broker configuration",
"mqtt not configured",
"not a SunSpec device",
"missing password", // Powerwall
"connect: no route to host",
"connect: connection refused",
"i/o timeout",
"connect: network is unreachable",
"no ping response for 192.0.2.2", // SMA
"network is unreachable",
"[1ESY1161052714 1ESY1161229249 1EMH0008842285 1ESY1161978584 1EMH0004864048 1ESY1161979033 7ELS8135823805]", // Discovergy
"can only have either uri or device", // modbus
"(Client.Timeout exceeded while awaiting headers)", // http
"cannot create meter 'discovergy': unexpected status: 401", //Discovergy Proxy
}
func TestMeterTemplates(t *testing.T) {
test.SkipCI(t)

View file

@ -146,8 +146,6 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evcc-io/config v0.0.0-20210930111050-37df6f7e52b8 h1:kfrzL89jpU+1fQ8Kyd3r9UI6wJ1KAABsFI0DrIR++/Q=
github.com/evcc-io/config v0.0.0-20210930111050-37df6f7e52b8/go.mod h1:aN5D6PVnoFvfZSMScvAQAIYRXwWOZ9lde3J0lsNRIOM=
github.com/evcc-io/eebus v0.0.0-20210928080925-1829ea71928f h1:jORYK0uKT+jJtpUxOZ8+cVLXKPASXioUPS9bnHNQfoA=
github.com/evcc-io/eebus v0.0.0-20210928080925-1829ea71928f/go.mod h1:2fJZDu2dSe7M6m+KIYkG5XPdk+Ws1ckuRyklZRvFzWE=
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=

View file

@ -1,35 +0,0 @@
package test
import (
"github.com/evcc-io/config/registry"
_ "github.com/evcc-io/config/templates" // import all config templates
"gopkg.in/yaml.v3"
)
// ConfigTemplate is a configuration template from https://github.com/evcc-io/config
type ConfigTemplate struct {
registry.Template
Config map[string]interface{}
}
// ConfigTemplates returns configuration templates for giving class
func ConfigTemplates(class string) (res []ConfigTemplate) {
templates := registry.TemplatesByClass(class)
for _, tmpl := range templates {
var conf map[string]interface{}
if err := yaml.Unmarshal([]byte(tmpl.Sample), &conf); err != nil {
// silently ignore errors here
continue
}
parsed := ConfigTemplate{
Template: tmpl,
Config: conf,
}
res = append(res, parsed)
}
return res
}

View file

@ -1,51 +0,0 @@
package vehicle
import (
"testing"
"github.com/evcc-io/evcc/util/test"
)
var acceptable = []string{
"invalid plugin type: ...",
"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",
"Missing required parameter", // Renault
"error connecting: Network Error",
"unexpected status: 401",
"could not obtain token", // Porsche
"missing credentials", // Tesla
"invalid vehicle type: hyundai",
"invalid vehicle type: kia",
"missing user, password or serial", // Niu
"missing credentials id", // Tronity
"missing access and/or refresh token, use `evcc token` to create", // Tesla
"login failed: Unauthorized: Authentication Failed", // Nissan
"login failed: no auth code", // Porsche
"invalid_client:Client authentication failed (e.g., login failure, unknown client, no client authentication included or unsupported authentication method)", // BMW, Mini
"login failed: oauth2: cannot fetch token: 400 Bad Request Response: {\"error\":\"invalid_request\",\"error_description\":\"Missing parameter, 'username'\"}", // Opel, DS, Citroen, PSA
}
func TestConfigVehicles(t *testing.T) {
test.SkipCI(t)
for _, tmpl := range test.ConfigTemplates("vehicle") {
tmpl := tmpl
t.Run(tmpl.Name, func(t *testing.T) {
t.Parallel()
_, err := NewFromConfig(tmpl.Type, tmpl.Config)
if err != nil && !test.Acceptable(err, acceptable) {
t.Logf("%s: %+v", tmpl.Name, tmpl.Config)
t.Error(err)
}
})
}
}

View file

@ -7,6 +7,32 @@ import (
"github.com/evcc-io/evcc/util/test"
)
var acceptable = []string{
"invalid plugin type: ...",
"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",
"Missing required parameter", // Renault
"error connecting: Network Error",
"unexpected status: 401",
"could not obtain token", // Porsche
"missing credentials", // Tesla
"invalid vehicle type: hyundai",
"invalid vehicle type: kia",
"missing user, password or serial", // Niu
"missing credentials id", // Tronity
"missing access and/or refresh token, use `evcc token` to create", // Tesla
"login failed: Unauthorized: Authentication Failed", // Nissan
"login failed: no auth code", // Porsche
"invalid_client:Client authentication failed (e.g., login failure, unknown client, no client authentication included or unsupported authentication method)", // BMW, Mini
"login failed: oauth2: cannot fetch token: 400 Bad Request Response: {\"error\":\"invalid_request\",\"error_description\":\"Missing parameter, 'username'\"}", // Opel, DS, Citroen, PSA
}
func TestVehicleTemplates(t *testing.T) {
test.SkipCI(t)