MCPcopy Create free account
hub / github.com/docker/secrets-engine / waitForReady

Function waitForReady

plugins/pass/commands/run_test.go:299–320  ·  view source on GitHub ↗
(t *testing.T, r io.Reader)

Source from the content-addressed store, hash-verified

297}
298
299func waitForReady(t *testing.T, r io.Reader) {
300 t.Helper()
301 scanner := bufio.NewScanner(r)
302 done := make(chan bool, 1)
303 go func() {
304 for scanner.Scan() {
305 if scanner.Text() == "READY" {
306 done <- true
307 return
308 }
309 }
310 done <- false
311 }()
312 select {
313 case ok := <-done:
314 require.True(t, ok, "subprocess closed stderr before printing READY")
315 case <-time.After(5 * time.Second):
316 t.Fatal("timed out waiting for READY from subprocess")
317 }
318 // Drain remaining stderr in the background so the pipe never blocks.
319 go func() { _, _ = io.Copy(io.Discard, r) }()
320}
321
322// testWriter forwards cobra output to t.Log so it does not leak onto stderr.
323type testWriter struct{ t *testing.T }

Callers 1

TestRunCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected