MCPcopy Index your code
hub / github.com/ddev/ddev / TestCaptureOutputToFile

Function TestCaptureOutputToFile

pkg/util/utils_test.go:117–136  ·  view source on GitHub ↗

TestCaptureOutputToFile tests CaptureOutputToFile.

(t *testing.T)

Source from the content-addressed store, hash-verified

115
116// TestCaptureOutputToFile tests CaptureOutputToFile.
117func TestCaptureOutputToFile(t *testing.T) {
118 assert := asrt.New(t)
119 restoreOutput, err := util.CaptureOutputToFile()
120 assert.NoError(err)
121 text := util.RandString(128)
122 fmt.Println("randstring-println=" + text)
123 c := exec.Command("sh", "-c", fmt.Sprintf("echo randstring-stdout=%s; echo 1>&2 randstring-stderr=%s", text, text))
124 c.Stdout = os.Stdout
125 c.Stderr = os.Stderr
126 err = c.Start()
127 assert.NoError(err)
128 err = c.Wait()
129 assert.NoError(err)
130
131 out := restoreOutput()
132
133 assert.Contains(out, "randstring-println="+text)
134 assert.Contains(out, "randstring-stdout="+text)
135 assert.Contains(out, "randstring-stderr="+text)
136}
137
138// TestConfirmTo ensures that the confirmation prompt works as expected.
139func TestConfirmTo(t *testing.T) {

Callers

nothing calls this directly

Calls 5

CaptureOutputToFileFunction · 0.92
RandStringFunction · 0.92
CommandMethod · 0.80
StartMethod · 0.80
WaitMethod · 0.80

Tested by

no test coverage detected