Skip to content

Commit cfa098f

Browse files
committed
ns: Add unit test for device update with MAC settings profile
1 parent cdb3cde commit cfa098f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

pkg/networkserver/grpc_deviceregistry_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ func TestDeviceRegistrySet(t *testing.T) {
437437
}
438438

439439
macSettingsProfileOpt := EndDeviceOptions.WithMacSettingsProfileIds(macSettingsProfileID)
440+
emptyMacSettingsProfileOpt := EndDeviceOptions.WithMacSettingsProfileIds(nil)
440441

441442
for createDevice, tcs := range map[*ttnpb.EndDevice][]struct {
442443
SetDevice SetDeviceRequest
@@ -811,6 +812,50 @@ func TestDeviceRegistrySet(t *testing.T) {
811812
StoredDevice: multicastClassBMACSettingsOpt(MakeMulticastEndDevice(ttnpb.Class_CLASS_B, defaultMACSettings, true, activeSessionOptsWithStartedAt, nil)),
812813
},
813814
},
815+
// Update with MAC settings profile
816+
MakeOTAAEndDevice(): {
817+
{
818+
SetDevice: *makeUpdateDeviceRequest([]test.EndDeviceOption{
819+
EndDeviceOptions.WithLorawanVersion(ttnpb.MACVersion_MAC_V1_0_3),
820+
EndDeviceOptions.WithLorawanPhyVersion(ttnpb.PHYVersion_RP001_V1_0_3_REV_A),
821+
EndDeviceOptions.WithDefaultFrequencyPlanID(),
822+
macSettingsProfileOpt,
823+
},
824+
"frequency_plan_id",
825+
"lorawan_version",
826+
"lorawan_phy_version",
827+
"mac_settings_profile_ids",
828+
),
829+
830+
ReturnedDevice: MakeOTAAEndDevice(
831+
EndDeviceOptions.WithLorawanVersion(ttnpb.MACVersion_MAC_V1_0_3),
832+
EndDeviceOptions.WithLorawanPhyVersion(ttnpb.PHYVersion_RP001_V1_0_3_REV_A),
833+
EndDeviceOptions.WithDefaultFrequencyPlanID(),
834+
macSettingsProfileOpt,
835+
),
836+
StoredDevice: MakeOTAAEndDevice(
837+
EndDeviceOptions.WithLorawanVersion(ttnpb.MACVersion_MAC_V1_0_3),
838+
EndDeviceOptions.WithLorawanPhyVersion(ttnpb.PHYVersion_RP001_V1_0_3_REV_A),
839+
EndDeviceOptions.WithDefaultFrequencyPlanID(),
840+
macSettingsProfileOpt,
841+
),
842+
},
843+
},
844+
// Update with empty MAC settings profile
845+
MakeOTAAEndDevice(macSettingsProfileOpt): {
846+
{
847+
SetDevice: *makeUpdateDeviceRequest([]test.EndDeviceOption{
848+
emptyMacSettingsProfileOpt,
849+
},
850+
"mac_settings_profile_ids",
851+
),
852+
853+
ReturnedDevice: MakeOTAAEndDevice(),
854+
StoredDevice: MakeOTAAEndDevice(
855+
customMACSettingsOpt,
856+
),
857+
},
858+
},
814859
} {
815860
for _, tc := range tcs {
816861
createDevice := createDevice

0 commit comments

Comments
 (0)