Testing faulty code (double run, etc.)
(t *testing.T)
| 39 | // Testing faulty code (double run, etc.) |
| 40 | |
| 41 | func TestFaultyDoubleRunWait(t *testing.T) { |
| 42 | // Double run returns an error on the second run, but Wait will still work properly |
| 43 | t.Parallel() |
| 44 | |
| 45 | command := &com.Command{ |
| 46 | Binary: "printf", |
| 47 | Args: []string{"one"}, |
| 48 | Timeout: time.Second, |
| 49 | } |
| 50 | |
| 51 | err := command.Run(context.WithValue(context.Background(), com.LoggerKey, t)) |
| 52 | |
| 53 | assertive.ErrorIsNil(t, err, "Err") |
| 54 | |
| 55 | err = command.Run(context.WithValue(context.Background(), com.LoggerKey, t)) |
| 56 | |
| 57 | assertive.ErrorIs(t, err, com.ErrExecAlreadyStarted, "Err") |
| 58 | |
| 59 | res, err := command.Wait() |
| 60 | |
| 61 | assertive.ErrorIsNil(t, err, "Err") |
| 62 | assertive.IsEqual(t, expect.ExitCodeSuccess, res.ExitCode, "ExitCode") |
| 63 | assertive.IsEqual(t, "one", res.Stdout, "Stdout") |
| 64 | assertive.IsEqual(t, "", res.Stderr, "Stderr") |
| 65 | } |
| 66 | |
| 67 | func TestFaultyRunDoubleWait(t *testing.T) { |
| 68 | // Double wait returns an error on the second wait, but also returns the existing result |
nothing calls this directly
no test coverage detected
searching dependent graphs…