| 108 | } |
| 109 | |
| 110 | func TestCloserStack_Context(t *testing.T) { |
| 111 | t.Parallel() |
| 112 | ctx := testutil.Context(t, testutil.WaitShort) |
| 113 | ctx, cancel := context.WithCancel(ctx) |
| 114 | defer cancel() |
| 115 | logger := testutil.Logger(t) |
| 116 | uut := newCloserStack(ctx, logger, quartz.NewMock(t)) |
| 117 | closes := new([]*fakeCloser) |
| 118 | fc0 := &fakeCloser{closes: closes} |
| 119 | fc1 := &fakeCloser{closes: closes} |
| 120 | |
| 121 | err := uut.push("fc0", fc0) |
| 122 | require.NoError(t, err) |
| 123 | err = uut.push("fc1", fc1) |
| 124 | require.NoError(t, err) |
| 125 | cancel() |
| 126 | require.Eventually(t, func() bool { |
| 127 | uut.Lock() |
| 128 | defer uut.Unlock() |
| 129 | return uut.closed |
| 130 | }, testutil.WaitShort, testutil.IntervalFast) |
| 131 | } |
| 132 | |
| 133 | func TestCloserStack_PushAfterClose(t *testing.T) { |
| 134 | t.Parallel() |