MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestValidatorForDeviceIDs

Function TestValidatorForDeviceIDs

pkg/unique/unique_test.go:250–379  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

248}
249
250func TestValidatorForDeviceIDs(t *testing.T) {
251 a := assertions.New(t)
252 for _, tc := range []struct {
253 Name string
254 InputUID string
255 ExpectedIdentifier ttnpb.EndDeviceIdentifiers
256 ExpectedError func(error) bool
257 }{
258 {
259 "ValidID",
260 "foo-app.foo-device",
261 ttnpb.EndDeviceIdentifiers{
262 ApplicationIds: &ttnpb.ApplicationIdentifiers{
263 ApplicationId: "foo-app",
264 },
265 DeviceId: "foo-device",
266 },
267 nil,
268 },
269 {
270 "ValidAppIDValidMinLength",
271 "foo-app.foo",
272 ttnpb.EndDeviceIdentifiers{
273 ApplicationIds: &ttnpb.ApplicationIdentifiers{
274 ApplicationId: "foo-app",
275 },
276 DeviceId: "foo",
277 },
278 nil,
279 },
280 {
281 "ValidAppIDValidMaxLength",
282 "foo-app.ozaj8qs0sait7oudxqbfyx6b14yuahcfrdlb",
283 ttnpb.EndDeviceIdentifiers{
284 ApplicationIds: &ttnpb.ApplicationIdentifiers{
285 ApplicationId: "foo-app",
286 },
287 DeviceId: "ozaj8qs0sait7oudxqbfyx6b14yuahcfrdlb",
288 },
289 nil,
290 },
291 {
292 "ValidAppIDValidNumerics",
293 "foo-app.1d1",
294 ttnpb.EndDeviceIdentifiers{
295 ApplicationIds: &ttnpb.ApplicationIdentifiers{
296 ApplicationId: "foo-app",
297 },
298 DeviceId: "1d1",
299 },
300 nil,
301 },
302 {
303 "InvalidFormat",
304 "foo-appfoo-device",
305 ttnpb.EndDeviceIdentifiers{},
306 errors.IsInvalidArgument,
307 },

Callers

nothing calls this directly

Calls 3

ToDeviceIDFunction · 0.85
NewMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected