runMigrateConfig runs the full migrate config pipeline end-to-end, capturing stdout. Warnings printed to stderr are not captured here.
(t *testing.T, inputFile, kafkaAddress, kafkaTopic, mode string)
| 362 | // runMigrateConfig runs the full migrate config pipeline end-to-end, capturing |
| 363 | // stdout. Warnings printed to stderr are not captured here. |
| 364 | func runMigrateConfig(t *testing.T, inputFile, kafkaAddress, kafkaTopic, mode string) (stdout string, err error) { |
| 365 | t.Helper() |
| 366 | cmd := &migrateConfigCmd{ |
| 367 | ConfigFile: inputFile, |
| 368 | KafkaAddress: kafkaAddress, |
| 369 | KafkaTopic: kafkaTopic, |
| 370 | Mode: mode, |
| 371 | } |
| 372 | |
| 373 | // Capture stdout. |
| 374 | orig := os.Stdout |
| 375 | r, w, _ := os.Pipe() |
| 376 | os.Stdout = w |
| 377 | defer func() { os.Stdout = orig }() |
| 378 | |
| 379 | done := make(chan struct{}) |
| 380 | var buf bytes.Buffer |
| 381 | go func() { |
| 382 | _, _ = io.Copy(&buf, r) |
| 383 | close(done) |
| 384 | }() |
| 385 | |
| 386 | err = cmd.Run(nil) |
| 387 | _ = w.Close() |
| 388 | <-done |
| 389 | return buf.String(), err |
| 390 | } |
| 391 | |
| 392 | func TestMigrateConfigEndToEnd(t *testing.T) { |
| 393 | tests := []struct { |
no test coverage detected