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