ExecCommand executes the command string with the devpod test binary
(ctx context.Context, captureStdOut, searchForString bool, searchString string, args []string)
| 40 | |
| 41 | // ExecCommand executes the command string with the devpod test binary |
| 42 | func (f *Framework) ExecCommand(ctx context.Context, captureStdOut, searchForString bool, searchString string, args []string) error { |
| 43 | var execOut bytes.Buffer |
| 44 | |
| 45 | cmd := exec.CommandContext(ctx, filepath.Join(f.DevpodBinDir, f.DevpodBinName), args...) |
| 46 | cmd.Stdout = io.MultiWriter(os.Stdout, &execOut) |
| 47 | cmd.Stderr = os.Stderr |
| 48 | |
| 49 | if err := cmd.Run(); err != nil { |
| 50 | return err |
| 51 | } |
| 52 | |
| 53 | if captureStdOut && searchForString { |
| 54 | if strings.Contains(execOut.String(), searchString) { |
| 55 | return nil |
| 56 | } |
| 57 | |
| 58 | return fmt.Errorf("expected to find string %s in output", searchString) |
| 59 | } |
| 60 | |
| 61 | return nil |
| 62 | } |
| 63 | |
| 64 | // ExecCommandCapture executes the command string with the devpod test binary, and returns stdout, stderr, and any error that occurred. |
| 65 | func (f *Framework) ExecCommandCapture(ctx context.Context, args []string) (string, string, error) { |
no test coverage detected