mirror of https://github.com/docker/cli.git
e2e/cli-plugins: use cmd.CombinedOutput() instead of custom buffer
Also remove a debug-log, as the output would already be shown if the test would fail. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c6b40640cc
commit
baf35da401
|
@ -1,7 +1,6 @@
|
||||||
package cliplugins
|
package cliplugins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"io"
|
"io"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -178,9 +177,6 @@ func TestPluginSocketCommunication(t *testing.T) {
|
||||||
t.Run("the plugin does not get signalled", func(t *testing.T) {
|
t.Run("the plugin does not get signalled", func(t *testing.T) {
|
||||||
cmd := run("presocket", "test-socket")
|
cmd := run("presocket", "test-socket")
|
||||||
command := exec.Command(cmd.Command[0], cmd.Command[1:]...)
|
command := exec.Command(cmd.Command[0], cmd.Command[1:]...)
|
||||||
outB := bytes.Buffer{}
|
|
||||||
command.Stdout = &outB
|
|
||||||
command.Stderr = &outB
|
|
||||||
command.SysProcAttr = &syscall.SysProcAttr{
|
command.SysProcAttr = &syscall.SysProcAttr{
|
||||||
Setpgid: true,
|
Setpgid: true,
|
||||||
}
|
}
|
||||||
|
@ -191,14 +187,13 @@ func TestPluginSocketCommunication(t *testing.T) {
|
||||||
err := syscall.Kill(command.Process.Pid, syscall.SIGINT)
|
err := syscall.Kill(command.Process.Pid, syscall.SIGINT)
|
||||||
assert.NilError(t, err, "failed to signal CLI process")
|
assert.NilError(t, err, "failed to signal CLI process")
|
||||||
}()
|
}()
|
||||||
err := command.Run()
|
out, err := command.CombinedOutput()
|
||||||
t.Log(outB.String())
|
|
||||||
assert.ErrorContains(t, err, "exit status 2")
|
assert.ErrorContains(t, 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
|
||||||
const expected = "test-socket: exiting after context was done"
|
const expected = "test-socket: exiting after context was done"
|
||||||
actual := strings.TrimSpace(outB.String())
|
actual := strings.TrimSpace(string(out))
|
||||||
assert.Check(t, is.Equal(actual, expected))
|
assert.Check(t, is.Equal(actual, expected))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue