@@ -22,10 +22,12 @@ import (
2222
2323 "github.com/plgd-dev/device/v2/client"
2424 "github.com/plgd-dev/device/v2/client/core"
25+ "github.com/plgd-dev/device/v2/pkg/net/coap"
2526 "github.com/plgd-dev/device/v2/schema/configuration"
2627 "github.com/plgd-dev/device/v2/schema/device"
2728 "github.com/plgd-dev/device/v2/schema/interfaces"
2829 "github.com/plgd-dev/device/v2/test"
30+ "github.com/plgd-dev/go-coap/v3/message/codes"
2931 "github.com/stretchr/testify/require"
3032)
3133
@@ -40,7 +42,7 @@ func TestClientUpdateResource(t *testing.T) {
4042 tests := []struct {
4143 name string
4244 args args
43- want interface {}
45+ want coap. DetailedResponse [ interface {}]
4446 wantErr bool
4547 }{
4648 {
@@ -53,8 +55,11 @@ func TestClientUpdateResource(t *testing.T) {
5355 },
5456 opts : []client.UpdateOption {client .WithDiscoveryConfiguration (core .DefaultDiscoveryConfiguration ())},
5557 },
56- want : map [interface {}]interface {}{
57- "n" : t .Name () + "-valid" ,
58+ want : coap.DetailedResponse [interface {}]{
59+ Code : codes .Changed ,
60+ Body : map [interface {}]interface {}{
61+ "n" : t .Name () + "-valid" ,
62+ },
5863 },
5964 },
6065 {
@@ -67,8 +72,11 @@ func TestClientUpdateResource(t *testing.T) {
6772 },
6873 opts : []client.UpdateOption {client .WithInterface (interfaces .OC_IF_BASELINE )},
6974 },
70- want : map [interface {}]interface {}{
71- "n" : t .Name () + "-valid with interface" ,
75+ want : coap.DetailedResponse [interface {}]{
76+ Code : codes .Changed ,
77+ Body : map [interface {}]interface {}{
78+ "n" : t .Name () + "-valid with interface" ,
79+ },
7280 },
7381 },
7482 {
@@ -80,8 +88,11 @@ func TestClientUpdateResource(t *testing.T) {
8088 "n" : test .DevsimName ,
8189 },
8290 },
83- want : map [interface {}]interface {}{
84- "n" : test .DevsimName ,
91+ want : coap.DetailedResponse [interface {}]{
92+ Code : codes .Changed ,
93+ Body : map [interface {}]interface {}{
94+ "n" : test .DevsimName ,
95+ },
8596 },
8697 },
8798 {
@@ -120,7 +131,7 @@ func TestClientUpdateResource(t *testing.T) {
120131
121132 for _ , tt := range tests {
122133 t .Run (tt .name , func (t * testing.T ) {
123- var got interface {}
134+ var got coap. DetailedResponse [ interface {}]
124135 err = c .UpdateResource (ctx , tt .args .deviceID , tt .args .href , tt .args .data , & got , tt .args .opts ... )
125136 if tt .wantErr {
126137 require .Error (t , err )
@@ -143,7 +154,7 @@ func TestClientUpdateResourceInRFOTM(t *testing.T) {
143154 tests := []struct {
144155 name string
145156 args args
146- want interface {}
157+ want coap. DetailedResponse [ interface {}]
147158 wantErr bool
148159 }{
149160 {
@@ -156,10 +167,13 @@ func TestClientUpdateResourceInRFOTM(t *testing.T) {
156167 },
157168 opts : []client.UpdateOption {client .WithDiscoveryConfiguration (core .DefaultDiscoveryConfiguration ())},
158169 },
159- want : map [interface {}]interface {}{
160- "name" : "Light" ,
161- "power" : uint64 (0 ),
162- "state" : true ,
170+ want : coap.DetailedResponse [interface {}]{
171+ Code : codes .Content ,
172+ Body : map [interface {}]interface {}{
173+ "name" : "Light" ,
174+ "power" : uint64 (0 ),
175+ "state" : true ,
176+ },
163177 },
164178 },
165179 {
@@ -172,10 +186,13 @@ func TestClientUpdateResourceInRFOTM(t *testing.T) {
172186 },
173187 opts : []client.UpdateOption {client .WithInterface (interfaces .OC_IF_BASELINE )},
174188 },
175- want : map [interface {}]interface {}{
176- "name" : "Light" ,
177- "power" : uint64 (1 ),
178- "state" : true ,
189+ want : coap.DetailedResponse [interface {}]{
190+ Code : codes .Content ,
191+ Body : map [interface {}]interface {}{
192+ "name" : "Light" ,
193+ "power" : uint64 (1 ),
194+ "state" : true ,
195+ },
179196 },
180197 },
181198 {
@@ -188,10 +205,13 @@ func TestClientUpdateResourceInRFOTM(t *testing.T) {
188205 "power" : uint64 (0 ),
189206 },
190207 },
191- want : map [interface {}]interface {}{
192- "name" : "Light" ,
193- "power" : uint64 (0 ),
194- "state" : false ,
208+ want : coap.DetailedResponse [interface {}]{
209+ Code : codes .Content ,
210+ Body : map [interface {}]interface {}{
211+ "name" : "Light" ,
212+ "power" : uint64 (0 ),
213+ "state" : false ,
214+ },
195215 },
196216 },
197217 {
@@ -235,9 +255,10 @@ func TestClientUpdateResourceInRFOTM(t *testing.T) {
235255 return
236256 }
237257 require .NoError (t , err )
238- var got interface {}
258+ var got coap. DetailedResponse [ interface {}]
239259 err = c .GetResource (ctx , tt .args .deviceID , tt .args .href , & got )
240260 require .NoError (t , err )
261+ got .ETag = nil
241262 require .Equal (t , tt .want , got )
242263 })
243264 }
0 commit comments