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

Function TestInitTaskGroup

pkg/redis/redis_test.go:33–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestInitTaskGroup(t *testing.T) {
34 for _, tc := range []struct {
35 Name string
36 Populate func(context.Context, *Client) bool
37 Group, Key string
38 ErrorAssertion func(*testing.T, error) bool
39 }{
40 {
41 Name: "no streams/no groups",
42 Populate: func(ctx context.Context, cl *Client) bool { return true },
43 Group: "testGroup",
44 Key: "testKey",
45 ErrorAssertion: func(t *testing.T, err error) bool { return assertions.New(t).So(err, should.BeNil) },
46 },
47 {
48 Name: "streams exist/groups exist",
49 Populate: func(ctx context.Context, cl *Client) bool {
50 _, a := test.MustNewTFromContext(ctx)
51 _, err := cl.XGroupCreateMkStream(ctx, InputTaskKey(cl.Key("testKey")), cl.Key("testGroup"), "0").Result()
52 if !a.So(err, should.BeNil) {
53 return false
54 }
55 _, err = cl.XGroupCreateMkStream(ctx, ReadyTaskKey(cl.Key("testKey")), cl.Key("testGroup"), "0").Result()
56 return a.So(err, should.BeNil)
57 },
58 Group: "testGroup",
59 Key: "testKey",
60 ErrorAssertion: func(t *testing.T, err error) bool { return assertions.New(t).So(err, should.BeNil) },
61 },
62 } {
63 test.RunSubtest(t, test.SubtestConfig{
64 Name: tc.Name,
65 Parallel: true,
66 Func: func(ctx context.Context, t *testing.T, a *assertions.Assertion) {
67 cl, flush := test.NewRedis(ctx, "redis_test")
68 defer flush()
69 defer cl.Close()
70
71 a.So(tc.Populate(ctx, cl), should.BeTrue)
72
73 err := InitTaskGroup(ctx, cl, cl.Key(tc.Group), cl.Key(tc.Key))
74 a.So(tc.ErrorAssertion(t, err), should.BeTrue)
75 },
76 })
77 }
78}
79
80func TestAddTask(t *testing.T) {
81 a, ctx := test.New(t)

Callers

nothing calls this directly

Calls 10

MustNewTFromContextFunction · 0.92
RunSubtestFunction · 0.92
NewRedisFunction · 0.92
InputTaskKeyFunction · 0.85
ReadyTaskKeyFunction · 0.85
PopulateMethod · 0.80
NewMethod · 0.65
ResultMethod · 0.65
KeyMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected