mirror of https://github.com/docker/cli.git
e2e/cli-plugins: check for exit-errors in tests
Verify that we get the expected exit-code, not just the message. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
baf35da401
commit
2f83064ec4
|
@ -1,6 +1,7 @@
|
||||||
package cliplugins
|
package cliplugins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -131,7 +132,12 @@ func TestPluginSocketBackwardsCompatible(t *testing.T) {
|
||||||
assert.NilError(t, err, "failed to signal process group")
|
assert.NilError(t, err, "failed to signal process group")
|
||||||
}()
|
}()
|
||||||
out, err := command.CombinedOutput()
|
out, err := command.CombinedOutput()
|
||||||
assert.ErrorContains(t, err, "exit status 1")
|
|
||||||
|
var exitError *exec.ExitError
|
||||||
|
assert.Assert(t, errors.As(err, &exitError))
|
||||||
|
assert.Check(t, exitError.Exited())
|
||||||
|
assert.Check(t, is.Equal(exitError.ExitCode(), 1))
|
||||||
|
assert.Check(t, is.ErrorContains(err, "exit status 1"))
|
||||||
|
|
||||||
// the plugin process does not receive a SIGINT and does
|
// the plugin process does not receive a SIGINT and does
|
||||||
// the CLI cannot cancel it over the socket, so it kills
|
// the CLI cannot cancel it over the socket, so it kills
|
||||||
|
@ -188,7 +194,12 @@ func TestPluginSocketCommunication(t *testing.T) {
|
||||||
assert.NilError(t, err, "failed to signal CLI process")
|
assert.NilError(t, err, "failed to signal CLI process")
|
||||||
}()
|
}()
|
||||||
out, err := command.CombinedOutput()
|
out, err := command.CombinedOutput()
|
||||||
assert.ErrorContains(t, err, "exit status 2")
|
|
||||||
|
var exitError *exec.ExitError
|
||||||
|
assert.Assert(t, errors.As(err, &exitError))
|
||||||
|
assert.Check(t, exitError.Exited())
|
||||||
|
assert.Check(t, is.Equal(exitError.ExitCode(), 2))
|
||||||
|
assert.Check(t, is.ErrorContains(err, "exit status 2"))
|
||||||
|
|
||||||
// the plugin does not get signalled, but it does get its
|
// the plugin does not get signalled, but it does get its
|
||||||
// context canceled by the CLI through the socket
|
// context canceled by the CLI through the socket
|
||||||
|
@ -222,7 +233,12 @@ func TestPluginSocketCommunication(t *testing.T) {
|
||||||
assert.NilError(t, err, "failed to signal CLI process§")
|
assert.NilError(t, err, "failed to signal CLI process§")
|
||||||
}()
|
}()
|
||||||
out, err := command.CombinedOutput()
|
out, err := command.CombinedOutput()
|
||||||
assert.ErrorContains(t, err, "exit status 1")
|
|
||||||
|
var exitError *exec.ExitError
|
||||||
|
assert.Assert(t, errors.As(err, &exitError))
|
||||||
|
assert.Check(t, exitError.Exited())
|
||||||
|
assert.Check(t, is.Equal(exitError.ExitCode(), 1))
|
||||||
|
assert.Check(t, is.ErrorContains(err, "exit status 1"))
|
||||||
|
|
||||||
// the plugin process does not receive a SIGINT and does
|
// the plugin process does not receive a SIGINT and does
|
||||||
// not exit after having it's context canceled, so the CLI
|
// not exit after having it's context canceled, so the CLI
|
||||||
|
|
Loading…
Reference in New Issue