@@ -35,6 +35,7 @@ import (
35
35
"github.com/plgd-dev/device/v2/schema/platform"
36
36
"github.com/plgd-dev/device/v2/schema/plgdtime"
37
37
"github.com/plgd-dev/device/v2/schema/resources"
38
+ "github.com/plgd-dev/device/v2/schema/softwareupdate"
38
39
"github.com/plgd-dev/device/v2/test"
39
40
"github.com/plgd-dev/go-coap/v3/message/codes"
40
41
"github.com/stretchr/testify/assert"
@@ -412,6 +413,19 @@ func verifyBatchDiscoveryResponse(t *testing.T, deviceID string, resp coap.Detai
412
413
}
413
414
}
414
415
416
+ var expectedFirstBatchResources = []batchResource {
417
+ {device .ResourceURI , false },
418
+ {platform .ResourceURI , false },
419
+ {test .TestResourceLightInstanceHref ("1" ), false },
420
+ {cloud .ResourceURI , false },
421
+ {maintenance .ResourceURI , false },
422
+ {introspection .ResourceURI , false },
423
+ {configuration .ResourceURI , false },
424
+ {test .TestResourceSwitchesHref , false },
425
+ {plgdtime .ResourceURI , false },
426
+ {softwareupdate .ResourceURI , false },
427
+ }
428
+
415
429
func TestObservingDiscoveryResourceWithBatchInterface (t * testing.T ) {
416
430
testDevice (t , test .DevsimName , func (ctx context.Context , t * testing.T , c * client.Client , deviceID string ) {
417
431
h := makeObservationHandler ()
@@ -423,17 +437,7 @@ func TestObservingDiscoveryResourceWithBatchInterface(t *testing.T) {
423
437
err = res (& d )
424
438
require .NoError (t , err )
425
439
assert .NotEmpty (t , d .Body )
426
- expected := []batchResource {
427
- {device .ResourceURI , false },
428
- {platform .ResourceURI , false },
429
- {test .TestResourceLightInstanceHref ("1" ), false },
430
- {cloud .ResourceURI , false },
431
- {maintenance .ResourceURI , false },
432
- {introspection .ResourceURI , false },
433
- {configuration .ResourceURI , false },
434
- {test .TestResourceSwitchesHref , false },
435
- {plgdtime .ResourceURI , false },
436
- }
440
+ expected := expectedFirstBatchResources
437
441
verifyBatchDiscoveryResponse (t , deviceID , d , codes .Content , expected ... )
438
442
if ETagSupported {
439
443
require .NotEmpty (t , d .ETag )
@@ -513,17 +517,7 @@ func TestObserveDiscoveryResourceWithIncrementalChangesOnUpdate(t *testing.T) {
513
517
err = res (& d0 )
514
518
require .NoError (t , err )
515
519
assert .NotEmpty (t , d0 .Body )
516
- expected := []batchResource {
517
- {device .ResourceURI , false },
518
- {platform .ResourceURI , false },
519
- {test .TestResourceLightInstanceHref ("1" ), false },
520
- {cloud .ResourceURI , false },
521
- {maintenance .ResourceURI , false },
522
- {introspection .ResourceURI , false },
523
- {configuration .ResourceURI , false },
524
- {test .TestResourceSwitchesHref , false },
525
- {plgdtime .ResourceURI , false },
526
- }
520
+ expected := expectedFirstBatchResources
527
521
require .NotEmpty (t , d0 .ETag )
528
522
verifyBatchDiscoveryResponse (t , deviceID , d0 , codes .Content , expected ... )
529
523
etags := make ([][]byte , 0 , len (d0 .Body )- 1 )
@@ -621,17 +615,7 @@ func TestObserveDiscoveryResourceWithIncrementalChangesOnCreate(t *testing.T) {
621
615
err = res (& d0 )
622
616
require .NoError (t , err )
623
617
assert .NotEmpty (t , d0 .Body )
624
- expected := []batchResource {
625
- {device .ResourceURI , false },
626
- {platform .ResourceURI , false },
627
- {test .TestResourceLightInstanceHref ("1" ), false },
628
- {cloud .ResourceURI , false },
629
- {maintenance .ResourceURI , false },
630
- {introspection .ResourceURI , false },
631
- {configuration .ResourceURI , false },
632
- {test .TestResourceSwitchesHref , false },
633
- {plgdtime .ResourceURI , false },
634
- }
618
+ expected := expectedFirstBatchResources
635
619
require .NotEmpty (t , d0 .ETag )
636
620
verifyBatchDiscoveryResponse (t , deviceID , d0 , codes .Content , expected ... )
637
621
etags := make ([][]byte , 0 , len (d0 .Body )- 1 )
@@ -737,18 +721,8 @@ func TestObserveDiscoveryResourceWithIncrementalChangesOnDelete(t *testing.T) {
737
721
err = res (& d0 )
738
722
require .NoError (t , err )
739
723
assert .NotEmpty (t , d0 .Body )
740
- expected := []batchResource {
741
- {device .ResourceURI , false },
742
- {platform .ResourceURI , false },
743
- {test .TestResourceLightInstanceHref ("1" ), false },
744
- {cloud .ResourceURI , false },
745
- {maintenance .ResourceURI , false },
746
- {introspection .ResourceURI , false },
747
- {configuration .ResourceURI , false },
748
- {test .TestResourceSwitchesHref , false },
749
- {test .TestResourceSwitchesInstanceHref (switchID ), false },
750
- {plgdtime .ResourceURI , false },
751
- }
724
+ expected := expectedFirstBatchResources
725
+ expected = append (expected , batchResource {test .TestResourceSwitchesInstanceHref (switchID ), false })
752
726
require .NotEmpty (t , d0 .ETag )
753
727
verifyBatchDiscoveryResponse (t , deviceID , d0 , codes .Content , expected ... )
754
728
etags := make ([][]byte , 0 , len (d0 .Body )- 1 )
0 commit comments