VerifyCurlCmd executes the curl command with the given arguments and verifies the result against the expected output.
(t *testing.T, args []string, failureConfig *CurlFailureConfig)
| 627 | // VerifyCurlCmd executes the curl command with the given arguments and verifies |
| 628 | // the result against the expected output. |
| 629 | func VerifyCurlCmd(t *testing.T, args []string, failureConfig *CurlFailureConfig) { |
| 630 | top: |
| 631 | queryCmd := exec.Command("curl", args...) |
| 632 | output, err := queryCmd.Output() |
| 633 | if len(failureConfig.CurlErrMsg) > 0 { |
| 634 | // the curl command should have returned an non-zero code |
| 635 | require.Error(t, err, "the curl command should have failed") |
| 636 | if ee, ok := err.(*exec.ExitError); ok { |
| 637 | require.Contains(t, string(ee.Stderr), failureConfig.CurlErrMsg, |
| 638 | "the curl output does not contain the expected output") |
| 639 | } |
| 640 | } else { |
| 641 | require.NoError(t, err, "the curl command should have succeeded") |
| 642 | if err := verifyOutput(t, output, failureConfig); err == errRetryCurl { |
| 643 | goto top |
| 644 | } else { |
| 645 | require.NoError(t, err) |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | // AssignUids talks to zero to assign the given number of uids. |
| 651 | func AssignUids(num uint64) error { |