MCPcopy Index your code
hub / github.com/docker/cli / TestNewDockerCliAndOperators

Function TestNewDockerCliAndOperators

cli/command/cli_test.go:260–290  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

258}
259
260func TestNewDockerCliAndOperators(t *testing.T) {
261 outbuf := bytes.NewBuffer(nil)
262 errbuf := bytes.NewBuffer(nil)
263
264 cli, err := NewDockerCli(
265 WithInputStream(io.NopCloser(strings.NewReader("some input"))),
266 WithOutputStream(outbuf),
267 WithErrorStream(errbuf),
268 )
269 assert.NilError(t, err)
270 // Check streams are initialized
271 assert.Check(t, cli.In() != nil)
272 assert.Check(t, cli.Out() != nil)
273 assert.Check(t, cli.Err() != nil)
274 inputStream, err := io.ReadAll(cli.In())
275 assert.NilError(t, err)
276 assert.Equal(t, string(inputStream), "some input")
277
278 // Check output stream
279 _, err = fmt.Fprint(cli.Out(), "output")
280 assert.NilError(t, err)
281 outputStream, err := io.ReadAll(outbuf)
282 assert.NilError(t, err)
283 assert.Equal(t, string(outputStream), "output")
284 // Check error stream
285 _, err = fmt.Fprint(cli.Err(), "error")
286 assert.NilError(t, err)
287 errStream, err := io.ReadAll(errbuf)
288 assert.NilError(t, err)
289 assert.Equal(t, string(errStream), "error")
290}
291
292func TestInitializeShouldAlwaysCreateTheContextStore(t *testing.T) {
293 cli, err := NewDockerCli()

Callers

nothing calls this directly

Calls 7

InMethod · 0.95
OutMethod · 0.95
ErrMethod · 0.95
NewDockerCliFunction · 0.85
WithInputStreamFunction · 0.85
WithOutputStreamFunction · 0.85
WithErrorStreamFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…