e2e: Add a TestMain for cli plugins tests

This was omitted when these tests were added.

Adding this means that the tests now see the `$DOCKER_HOST` configured (via
`$TEST_DOCKER_HOST`) where they didn't before. In some cases (specifically the
`test-e2e-connhelper-ssh` case) this results in additional output on stderr
when `-D` (debug) is used:

    time="2019-04-03T11:10:27Z" level=debug msg="commandconn: starting ssh with [-l penguin 172.20.0.2 -- docker system dial-stdio]"

Address this by switching the affected test cases to use `-l info` instead of
`-D`, they all just require some option not specifically `-D`. Note that `info`
is the default log level so this is effectively a nop (which is good).

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell 2019-04-03 11:29:36 +01:00
parent add2da66c5
commit ef40743669
2 changed files with 22 additions and 5 deletions

View File

@ -0,0 +1,17 @@
package cliplugins
import (
"fmt"
"os"
"testing"
"github.com/docker/cli/internal/test/environment"
)
func TestMain(m *testing.M) {
if err := environment.Setup(); err != nil {
fmt.Println(err.Error())
os.Exit(3)
}
os.Exit(m.Run())
}

View File

@ -135,7 +135,7 @@ func TestHelpGood(t *testing.T) {
run, _, cleanup := prepare(t)
defer cleanup()
res := icmd.RunCmd(run("-D", "help", "helloworld"))
res := icmd.RunCmd(run("-l", "info", "help", "helloworld"))
res.Assert(t, icmd.Expected{
ExitCode: 0,
Err: icmd.None,
@ -150,7 +150,7 @@ func TestGoodHelp(t *testing.T) {
run, _, cleanup := prepare(t)
defer cleanup()
res := icmd.RunCmd(run("-D", "helloworld", "--help"))
res := icmd.RunCmd(run("-l", "info", "helloworld", "--help"))
res.Assert(t, icmd.Expected{
ExitCode: 0,
Err: icmd.None,
@ -159,7 +159,7 @@ func TestGoodHelp(t *testing.T) {
golden.Assert(t, res.Stdout(), "docker-help-helloworld.golden")
// Short -h should be the same, modulo the deprecation message
exp := shortHFlagDeprecated + res.Stdout()
res = icmd.RunCmd(run("-D", "helloworld", "-h"))
res = icmd.RunCmd(run("-l", "info", "helloworld", "-h"))
res.Assert(t, icmd.Expected{
ExitCode: 0,
// This should be identical to the --help case above
@ -188,7 +188,7 @@ func TestHelpGoodSubcommand(t *testing.T) {
run, _, cleanup := prepare(t)
defer cleanup()
res := icmd.RunCmd(run("-D", "help", "helloworld", "goodbye"))
res := icmd.RunCmd(run("-l", "info", "help", "helloworld", "goodbye"))
res.Assert(t, icmd.Expected{
ExitCode: 0,
Err: icmd.None,
@ -203,7 +203,7 @@ func TestGoodSubcommandHelp(t *testing.T) {
run, _, cleanup := prepare(t)
defer cleanup()
res := icmd.RunCmd(run("-D", "helloworld", "goodbye", "--help"))
res := icmd.RunCmd(run("-l", "info", "helloworld", "goodbye", "--help"))
res.Assert(t, icmd.Expected{
ExitCode: 0,
Err: icmd.None,