Also includes the scaffolding for finding a validating plugin candidates. Argument validation is moved to RunE to support this, so `noArgs` is removed. Signed-off-by: Ian Campbell <ijc@docker.com>
37 lines
889 B
Go
37 lines
889 B
Go
package manager
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/docker/cli/cli/config/configfile"
|
|
"github.com/docker/cli/internal/test"
|
|
"gotest.tools/assert"
|
|
)
|
|
|
|
func TestErrPluginNotFound(t *testing.T) {
|
|
var err error = errPluginNotFound("test")
|
|
err.(errPluginNotFound).NotFound()
|
|
assert.Error(t, err, "Error: No such CLI plugin: test")
|
|
assert.Assert(t, IsNotFound(err))
|
|
assert.Assert(t, !IsNotFound(nil))
|
|
}
|
|
|
|
func TestGetPluginDirs(t *testing.T) {
|
|
cli := test.NewFakeCli(nil)
|
|
|
|
expected := []string{defaultUserPluginDir}
|
|
expected = append(expected, defaultSystemPluginDirs...)
|
|
|
|
assert.Equal(t, strings.Join(expected, ":"), strings.Join(getPluginDirs(cli), ":"))
|
|
|
|
extras := []string{
|
|
"foo", "bar", "baz",
|
|
}
|
|
expected = append(extras, expected...)
|
|
cli.SetConfigFile(&configfile.ConfigFile{
|
|
CLIPluginsExtraDirs: extras,
|
|
})
|
|
assert.DeepEqual(t, expected, getPluginDirs(cli))
|
|
}
|