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:
24
e2e/cli-plugins/util_test.go
Normal file
24
e2e/cli-plugins/util_test.go
Normal 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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user