evcc-io/api/actionconfig_test.go
Michael Geers 5cc4c146ee
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled
Restore vehicle onIdentify behavior for targetSoc from yaml (#9685)
* Fix vehicle onIdentify for targetSoc

* fix onDisconnect behavior if config exists; update tests

* deprecated config-based minsoc; api/ui only setting

* fix tests
2023-09-03 16:29:13 +02:00

41 lines
601 B
Go

package api
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMerge(t *testing.T) {
pv := ModePV
one := 1
six := 6.0
old := ActionConfig{
Mode: &pv,
Priority: &one,
MinCurrent: &six,
}
now := ModeNow
two := 2
new := ActionConfig{
Mode: &now,
Priority: &two,
}
dst := old.Merge(new)
// unmodified
assert.Equal(t, old, ActionConfig{
Mode: &pv,
Priority: &one,
MinCurrent: &six,
}, "old modified")
// overwritten
assert.Equal(t, dst, ActionConfig{
Mode: &now,
MinCurrent: &six,
Priority: &two,
}, "new wrong")
}