Add some simple e2e tests for executing CLI plugins

To help with this add a bad plugin which produces invalid metadata and arrange
for it to be built in the e2e container.

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell
2018-12-11 14:15:04 +00:00
parent f1f31abbe5
commit 5db336798c
8 changed files with 110 additions and 2 deletions

View File

@ -0,0 +1,24 @@
package cliplugins
import (
"fmt"
"os"
"testing"
"gotest.tools/fs"
"gotest.tools/icmd"
)
func prepare(t *testing.T) (func(args ...string) icmd.Cmd, func()) {
cfg := fs.NewDir(t, "plugin-test",
fs.WithFile("config.json", fmt.Sprintf(`{"cliPluginsExtraDirs": [%q]}`, os.Getenv("DOCKER_CLI_E2E_PLUGINS_EXTRA_DIRS"))),
)
run := func(args ...string) icmd.Cmd {
return icmd.Command("docker", append([]string{"--config", cfg.Path()}, args...)...)
}
cleanup := func() {
cfg.Remove()
}
return run, cleanup
}