(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestFrameCheckInterrupt(t *testing.T) { |
| 26 | tests := []struct { |
| 27 | name string |
| 28 | setupCtx func(ctx context.Context, f *ExecutionFrame) (context.CancelFunc, func(int)) |
| 29 | checks []bool |
| 30 | }{ |
| 31 | { |
| 32 | name: "nil context", |
| 33 | checks: []bool{false, false}, |
| 34 | }, |
| 35 | { |
| 36 | name: "zero frequency not canceled", |
| 37 | setupCtx: func(ctx context.Context, f *ExecutionFrame) (context.CancelFunc, func(int)) { |
| 38 | f.SetContext(ctx, 0) |
| 39 | return nil, nil |
| 40 | }, |
| 41 | checks: []bool{false, false}, |
| 42 | }, |
| 43 | { |
| 44 | name: "frequency one not canceled", |
| 45 | setupCtx: func(ctx context.Context, f *ExecutionFrame) (context.CancelFunc, func(int)) { |
| 46 | f.SetContext(ctx, 1) |
| 47 | return nil, nil |
| 48 | }, |
| 49 | checks: []bool{false, false}, |
| 50 | }, |
| 51 | { |
| 52 | name: "frequency one canceled dynamically", |
| 53 | setupCtx: func(ctx context.Context, f *ExecutionFrame) (context.CancelFunc, func(int)) { |
| 54 | c, cancel := context.WithCancel(ctx) |
| 55 | f.SetContext(c, 1) |
| 56 | return nil, func(step int) { |
| 57 | if step == 1 { |
| 58 | cancel() |
| 59 | } |
| 60 | } |
| 61 | }, |
| 62 | checks: []bool{false, true, true}, |
| 63 | }, |
| 64 | { |
| 65 | name: "frequency two not canceled", |
| 66 | setupCtx: func(ctx context.Context, f *ExecutionFrame) (context.CancelFunc, func(int)) { |
| 67 | f.SetContext(ctx, 2) |
| 68 | return nil, nil |
| 69 | }, |
| 70 | checks: []bool{false, false, false}, |
| 71 | }, |
| 72 | { |
| 73 | name: "frequency two canceled dynamically", |
| 74 | setupCtx: func(ctx context.Context, f *ExecutionFrame) (context.CancelFunc, func(int)) { |
| 75 | c, cancel := context.WithCancel(ctx) |
| 76 | f.SetContext(c, 2) |
| 77 | return nil, func(step int) { |
| 78 | if step == 1 { |
| 79 | cancel() |
| 80 | } |
| 81 | } |
| 82 | }, |
nothing calls this directly
no test coverage detected