MCPcopy Index your code
hub / github.com/docker/cli / TestGetPlugin

Function TestGetPlugin

cli-plugins/manager/manager_test.go:112–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestGetPlugin(t *testing.T) {
113 dir := fs.NewDir(t, t.Name(),
114 fs.WithFile("docker-bbb", `
115#!/bin/sh
116echo '{"SchemaVersion":"0.1.0"}'`, fs.WithMode(0o777)),
117 fs.WithFile("docker-aaa", `
118#!/bin/sh
119echo '{"SchemaVersion":"0.1.0"}'`, fs.WithMode(0o777)),
120 )
121 defer dir.Remove()
122
123 cli := test.NewFakeCli(nil)
124 cli.SetConfigFile(&configfile.ConfigFile{CLIPluginsExtraDirs: []string{dir.Path()}})
125
126 plugin, err := GetPlugin("bbb", cli, &cobra.Command{})
127 assert.NilError(t, err)
128 assert.Equal(t, plugin.Name, "bbb")
129
130 _, err = GetPlugin("ccc", cli, &cobra.Command{})
131 assert.Error(t, err, "Error: No such CLI plugin: ccc")
132 assert.Assert(t, errdefs.IsNotFound(err))
133}
134
135func TestListPluginsIsSorted(t *testing.T) {
136 dir := fs.NewDir(t, t.Name(),

Callers

nothing calls this directly

Calls 6

SetConfigFileMethod · 0.95
GetPluginFunction · 0.85
RemoveMethod · 0.65
PathMethod · 0.65
NameMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…