(t *testing.T)
| 31 | ) |
| 32 | |
| 33 | func 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 | |
| 80 | func TestAddTask(t *testing.T) { |
| 81 | a, ctx := test.New(t) |
nothing calls this directly
no test coverage detected