Skip to content

Commit

Permalink
fix mocktr181 response struct
Browse files Browse the repository at this point in the history
  • Loading branch information
piccione99 committed Apr 10, 2024
1 parent d4dc401 commit aa50e73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/wrphandlers/mocktr181/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ func (h Handler) HandleWrp(msg wrp.Message) error {
}

func (h Handler) get(names []string) (int64, []byte, error) {
result := []Parameter{}
result := Tr181Payload{}

for _, name := range names {
for _, mockParameter := range h.parameters {
if strings.HasPrefix(mockParameter.Name, name) {
result = append(result, Parameter{
result.Parameters = append(result.Parameters, Parameter{
Name: mockParameter.Name,
Value: mockParameter.Value,
DataType: mockParameter.DataType,
Expand Down
4 changes: 2 additions & 2 deletions internal/wrphandlers/mocktr181/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func TestHandler_HandleWrp(t *testing.T) {
},
validate: func(a *assert.Assertions, msg wrp.Message, h *Handler) error {
a.Equal(int64(http.StatusOK), *msg.Status)
var result []Parameters
var result Tr181Payload
err := json.Unmarshal(msg.Payload, &result)
a.NoError(err)
a.Equal(102, len(result))
a.Equal(102, len(result.Parameters))
a.True(h.Enabled())
return nil
},
Expand Down

0 comments on commit aa50e73

Please sign in to comment.