Skip to content

Commit 27e854a

Browse files
andigclaude
andcommitted
Advertise Write in tests and cover the write-not-advertised path
Now that the Write() advertisement gate is present in the Hvac feature helper, the test fixture must advertise the Write operation for existing write tests to pass, and a dedicated test verifies WriteOperationMode returns ErrNotSupported when the remote advertises the system-function list as read-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0247111 commit 27e854a

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

usecases/ca/cdsf/public_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cdsf
22

33
import (
4+
"github.com/enbility/eebus-go/api"
45
ucapi "github.com/enbility/eebus-go/usecases/api"
56
"github.com/enbility/spine-go/model"
67
"github.com/enbility/spine-go/util"
@@ -156,6 +157,23 @@ func (s *CaCDSFSuite) Test_WriteOperationMode_AmbiguousSystemFunction() {
156157
assert.NotNil(s.T(), err)
157158
}
158159

160+
func (s *CaCDSFSuite) Test_WriteOperationMode_WriteNotAdvertised() {
161+
s.addHvacData(util.Ptr(true))
162+
163+
// re-advertise the system-function list as read-only
164+
rFeature := s.remoteDevice.FeatureByEntityTypeAndRole(s.dhwCircuitEntity, model.FeatureTypeTypeHvac, model.RoleTypeServer)
165+
rFeature.SetOperations([]model.FunctionPropertyType{
166+
{
167+
Function: util.Ptr(model.FunctionTypeHvacSystemFunctionListData),
168+
PossibleOperations: &model.PossibleOperationsType{Read: &model.PossibleOperationsReadType{}},
169+
},
170+
})
171+
172+
// the write must be rejected when the remote does not advertise Write()
173+
_, err := s.sut.WriteOperationMode(s.dhwCircuitEntity, ucapi.HvacOperationModeTypeOn, nil)
174+
assert.ErrorIs(s.T(), err, api.ErrNotSupported)
175+
}
176+
159177
// helpers
160178

161179
func (s *CaCDSFSuite) addOverrunData(isChangeable bool) {

usecases/ca/cdsf/testhelper_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ func setupDevices(
116116
supportedFct := model.FunctionPropertyType{
117117
Function: util.Ptr(fct),
118118
PossibleOperations: &model.PossibleOperationsType{
119-
Read: &model.PossibleOperationsReadType{},
119+
Read: &model.PossibleOperationsReadType{},
120+
Write: &model.PossibleOperationsWriteType{},
120121
},
121122
}
122123
supportedFcts = append(supportedFcts, supportedFct)

0 commit comments

Comments
 (0)