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

Function TestSessionKeyRegistries

pkg/joinserver/registry_test.go:603–660  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

601}
602
603func TestSessionKeyRegistries(t *testing.T) {
604 t.Parallel()
605
606 namespace := [...]string{
607 "joinserver_test",
608 }
609
610 for _, tc := range []struct {
611 Name string
612 New func(ctx context.Context) (KeyRegistry, func() error, error)
613 N uint16
614 }{
615 {
616 Name: "Redis",
617 New: func(ctx context.Context) (KeyRegistry, func() error, error) {
618 cl, flush := test.NewRedis(ctx, namespace[:]...)
619 keyReg := &redis.KeyRegistry{
620 Redis: cl,
621 LockTTL: test.Delay << 10,
622 Limit: 10,
623 }
624 if err := keyReg.Init(ctx); err != nil {
625 return nil, nil, err
626 }
627 return keyReg, func() error {
628 flush()
629 return cl.Close()
630 }, nil
631 },
632 N: 8,
633 },
634 } {
635 for i := 0; i < int(tc.N); i++ {
636 test.RunSubtest(t, test.SubtestConfig{
637 Name: fmt.Sprintf("%s/%d", tc.Name, i),
638 Parallel: true,
639 Func: func(ctx context.Context, t *testing.T, a *assertions.Assertion) {
640 reg, closeFn, err := tc.New(ctx)
641 if !a.So(err, should.BeNil) {
642 t.FailNow()
643 }
644 if closeFn != nil {
645 defer func() {
646 if err := closeFn(); err != nil {
647 t.Errorf("Failed to close registry: %s", err)
648 }
649 }()
650 }
651 t.Run("1st run", func(t *testing.T) { handleKeyRegistryTest(t, reg) })
652 if t.Failed() {
653 t.Skip("Skipping 2nd run")
654 }
655 t.Run("2nd run", func(t *testing.T) { handleKeyRegistryTest(t, reg) })
656 },
657 })
658 }
659 }
660}

Callers

nothing calls this directly

Calls 8

InitMethod · 0.95
NewRedisFunction · 0.92
RunSubtestFunction · 0.92
handleKeyRegistryTestFunction · 0.85
CloseMethod · 0.65
NewMethod · 0.65
ErrorfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected