Files
docker-cli/e2e/cli-plugins/util_test.go
Ian Campbell 5db336798c 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>
2019-01-30 13:44:05 +00:00

25 lines
521 B
Go

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
}