(t *testing.T)
| 258 | } |
| 259 | |
| 260 | func 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 | |
| 292 | func TestInitializeShouldAlwaysCreateTheContextStore(t *testing.T) { |
| 293 | cli, err := NewDockerCli() |
nothing calls this directly
no test coverage detected
searching dependent graphs…