chore: fix tests

This commit is contained in:
andig 2025-05-02 10:40:32 +02:00
parent cbc217919b
commit 467a7f8dab
2 changed files with 10 additions and 13 deletions

View file

@ -18,6 +18,7 @@ package charger
// SOFTWARE.
import (
"errors"
"fmt"
"net/http"
"strconv"
@ -68,12 +69,7 @@ func NewPlugchoiceFromConfig(other map[string]interface{}) (api.Charger, error)
return nil, err
}
// If both are provided, Identity takes precedence
if cc.Identity != "" || cc.UUID != "" {
return NewPlugchoice(cc.URI, cc.UUID, cc.Identity, cc.Connector, cc.Token, cc.Cache)
}
return nil, fmt.Errorf("either identity or uuid must be provided")
return NewPlugchoice(cc.URI, cc.UUID, cc.Identity, cc.Connector, cc.Token, cc.Cache)
}
// NewPlugchoice creates a Plugchoice charger
@ -92,6 +88,11 @@ func NewPlugchoice(uri, uuid, identity string, connector int, token string, cach
}
}
// If both are provided, Identity takes precedence
if identity == "" && uuid == "" {
return nil, errors.New("either identity or uuid are required")
}
// If identity is provided but no UUID, try to find the UUID
if uuid == "" && identity != "" {
var err error
@ -101,11 +102,6 @@ func NewPlugchoice(uri, uuid, identity string, connector int, token string, cach
}
}
// If we still don't have a UUID, return an error
if uuid == "" {
return nil, fmt.Errorf("either uuid or identity must be provided")
}
if !sponsor.IsAuthorized() {
return nil, api.ErrSponsorRequired
}

View file

@ -32,8 +32,9 @@ var acceptable = []string{
"sponsorship required, see https://docs.evcc.io/docs/sponsorship",
"eebus not configured",
"context deadline exceeded",
"timeout", // ocpp
"must have uri and password", // Wattpilot
"timeout", // ocpp
"must have uri and password", // Wattpilot
"either identity or uuid are required", // Plugchoice
}
func TestTemplates(t *testing.T) {