chore: fix data race in charger state tests (#32759)
This commit is contained in:
parent
d719585f1f
commit
082f84df95
1 changed files with 6 additions and 0 deletions
|
|
@ -157,7 +157,10 @@ func TestEasee_waitForChargerEnabledState(t *testing.T) {
|
||||||
|
|
||||||
if tc.updateState { // simulate state changes
|
if tc.updateState { // simulate state changes
|
||||||
go func() {
|
go func() {
|
||||||
|
// opMode is read under the lock by inExpectedOpMode
|
||||||
|
e.mux.Lock()
|
||||||
e.opMode = easee.ModeCharging // transition to charging
|
e.opMode = easee.ModeCharging // transition to charging
|
||||||
|
e.mux.Unlock()
|
||||||
if tc.sendObs {
|
if tc.sendObs {
|
||||||
e.obsC <- easee.Observation{
|
e.obsC <- easee.Observation{
|
||||||
ID: easee.CHARGER_OP_MODE,
|
ID: easee.CHARGER_OP_MODE,
|
||||||
|
|
@ -197,7 +200,10 @@ func TestEasee_waitForDynamicChargerCurrent(t *testing.T) {
|
||||||
|
|
||||||
if tc.updateState { // simulate state changes
|
if tc.updateState { // simulate state changes
|
||||||
go func() {
|
go func() {
|
||||||
|
// dynamicChargerCurrent is read under the lock by waitForDynamicChargerCurrent
|
||||||
|
e.mux.Lock()
|
||||||
e.dynamicChargerCurrent = 32 // transition to 32A
|
e.dynamicChargerCurrent = 32 // transition to 32A
|
||||||
|
e.mux.Unlock()
|
||||||
if tc.sendObs {
|
if tc.sendObs {
|
||||||
e.obsC <- easee.Observation{
|
e.obsC <- easee.Observation{
|
||||||
ID: easee.DYNAMIC_CHARGER_CURRENT,
|
ID: easee.DYNAMIC_CHARGER_CURRENT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue