(t *testing.T)
| 152 | } |
| 153 | |
| 154 | func TestCloserStack_CloseAfterContext(t *testing.T) { |
| 155 | t.Parallel() |
| 156 | testCtx := testutil.Context(t, testutil.WaitShort) |
| 157 | ctx, cancel := context.WithCancel(testCtx) |
| 158 | defer cancel() |
| 159 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug) |
| 160 | uut := newCloserStack(ctx, logger, quartz.NewMock(t)) |
| 161 | ac := newAsyncCloser(testCtx, t) |
| 162 | defer ac.unblock() |
| 163 | err := uut.push("async", ac) |
| 164 | require.NoError(t, err) |
| 165 | cancel() |
| 166 | testutil.TryReceive(testCtx, t, ac.started) |
| 167 | |
| 168 | closed := make(chan struct{}) |
| 169 | go func() { |
| 170 | defer close(closed) |
| 171 | uut.close(nil) |
| 172 | }() |
| 173 | |
| 174 | // since the asyncCloser is still waiting, we shouldn't complete uut.close() |
| 175 | select { |
| 176 | case <-time.After(testutil.IntervalFast): |
| 177 | // OK! |
| 178 | case <-closed: |
| 179 | t.Fatal("closed before stack was finished") |
| 180 | } |
| 181 | |
| 182 | ac.unblock() |
| 183 | testutil.TryReceive(testCtx, t, closed) |
| 184 | testutil.TryReceive(testCtx, t, ac.done) |
| 185 | } |
| 186 | |
| 187 | func TestCloserStack_Timeout(t *testing.T) { |
| 188 | t.Parallel() |
nothing calls this directly
no test coverage detected