Skip to content

Commit 2da3245

Browse files
committed
ns: Add unit test for setting a profile to a device
1 parent 06b65b3 commit 2da3245

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pkg/networkserver/grpc_deviceregistry_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@ func TestDeviceRegistrySet(t *testing.T) {
429429
}
430430
}
431431

432+
macSettingsProfileID := &ttnpb.MACSettingsProfileIdentifiers{
433+
ApplicationIds: &ttnpb.ApplicationIdentifiers{
434+
ApplicationId: "test-app-id",
435+
},
436+
ProfileId: "test-mac-settings-profile-id",
437+
}
438+
439+
macSettingsProfileOpt := EndDeviceOptions.WithMacSettingsProfileIds(macSettingsProfileID)
440+
432441
for createDevice, tcs := range map[*ttnpb.EndDevice][]struct {
433442
SetDevice SetDeviceRequest
434443
RequiredRights []ttnpb.Right
@@ -496,7 +505,20 @@ func TestDeviceRegistrySet(t *testing.T) {
496505
customMACSettingsOpt,
497506
),
498507
},
508+
{
509+
SetDevice: *MakeOTAASetDeviceRequest([]test.EndDeviceOption{
510+
macSettingsProfileOpt,
511+
},
512+
"mac_settings_profile_ids",
513+
),
499514

515+
ReturnedDevice: MakeOTAAEndDevice(
516+
macSettingsProfileOpt,
517+
),
518+
StoredDevice: MakeOTAAEndDevice(
519+
macSettingsProfileOpt,
520+
),
521+
},
500522
{
501523
SetDevice: *MakeOTAASetDeviceRequest([]test.EndDeviceOption{
502524
activateOpt,
@@ -857,6 +879,17 @@ func TestDeviceRegistrySet(t *testing.T) {
857879
clock.Add(time.Nanosecond)
858880
}
859881

882+
macSettingsProfile := &ttnpb.MACSettingsProfile{
883+
Ids: macSettingsProfileID,
884+
MacSettings: customMACSettings,
885+
}
886+
profile, err := env.MACSettingsProfileRegistry.Set(ctx, macSettingsProfileID, []string{"ids", "mac_settings"},
887+
func(context.Context, *ttnpb.MACSettingsProfile) (*ttnpb.MACSettingsProfile, []string, error) {
888+
return macSettingsProfile, []string{"ids", "mac_settings"}, nil
889+
})
890+
a.So(err, should.BeNil)
891+
a.So(profile, should.Resemble, macSettingsProfile)
892+
860893
now := clock.Now()
861894
withTimestamps := withCreatedAt.Compose(
862895
test.EndDeviceOptions.WithUpdatedAt(timestamppb.New(now)),

0 commit comments

Comments
 (0)