TestWaitPreStart_RaceRealErrorAndResult stress-tests the opposite scenario: a real transport error on Error races with a stale Result. The Error must always win — the function must never silently drop the failure and return success based on Result.
(t *testing.T)
| 357 | // always win — the function must never silently drop the failure and return |
| 358 | // success based on Result. |
| 359 | func TestWaitPreStart_RaceRealErrorAndResult(t *testing.T) { |
| 360 | for i := 0; i < 100; i++ { |
| 361 | resultC := make(chan container.WaitResponse, 1) |
| 362 | errC := make(chan error, 1) |
| 363 | resultC <- container.WaitResponse{StatusCode: 0} |
| 364 | errC <- fmt.Errorf("daemon: connection lost") |
| 365 | waitRes := client.ContainerWaitResult{Result: resultC, Error: errC} |
| 366 | err := waitPreStart(t.Context(), "web", 0, waitRes) |
| 367 | assert.ErrorContains(t, err, "connection lost") |
| 368 | } |
| 369 | } |
nothing calls this directly
no test coverage detected