66 "strings"
77 "testing"
88
9+ "github.com/docker/cli/cli-plugins/metadata"
910 "github.com/spf13/cobra"
1011 "gotest.tools/v3/assert"
1112 "gotest.tools/v3/assert/cmp"
@@ -30,10 +31,10 @@ func (c *fakeCandidate) Metadata() ([]byte, error) {
3031
3132func TestValidateCandidate (t * testing.T ) {
3233 const (
33- goodPluginName = NamePrefix + "goodplugin"
34+ goodPluginName = metadata . NamePrefix + "goodplugin"
3435
35- builtinName = NamePrefix + "builtin"
36- builtinAlias = NamePrefix + "alias"
36+ builtinName = metadata . NamePrefix + "builtin"
37+ builtinAlias = metadata . NamePrefix + "alias"
3738
3839 badPrefixPath = "/usr/local/libexec/cli-plugins/wobble"
3940 badNamePath = "/usr/local/libexec/cli-plugins/docker-123456"
@@ -43,9 +44,9 @@ func TestValidateCandidate(t *testing.T) {
4344
4445 fakeroot := & cobra.Command {Use : "docker" }
4546 fakeroot .AddCommand (& cobra.Command {
46- Use : strings .TrimPrefix (builtinName , NamePrefix ),
47+ Use : strings .TrimPrefix (builtinName , metadata . NamePrefix ),
4748 Aliases : []string {
48- strings .TrimPrefix (builtinAlias , NamePrefix ),
49+ strings .TrimPrefix (builtinAlias , metadata . NamePrefix ),
4950 },
5051 })
5152
@@ -59,7 +60,7 @@ func TestValidateCandidate(t *testing.T) {
5960 }{
6061 /* Each failing one of the tests */
6162 {name : "empty path" , c : & fakeCandidate {path : "" }, err : "plugin candidate path cannot be empty" },
62- {name : "bad prefix" , c : & fakeCandidate {path : badPrefixPath }, err : fmt .Sprintf ("does not have %q prefix" , NamePrefix )},
63+ {name : "bad prefix" , c : & fakeCandidate {path : badPrefixPath }, err : fmt .Sprintf ("does not have %q prefix" , metadata . NamePrefix )},
6364 {name : "bad path" , c : & fakeCandidate {path : badNamePath }, invalid : "did not match" },
6465 {name : "builtin command" , c : & fakeCandidate {path : builtinName }, invalid : `plugin "builtin" duplicates builtin command` },
6566 {name : "builtin alias" , c : & fakeCandidate {path : builtinAlias }, invalid : `plugin "alias" duplicates an alias of builtin command "builtin"` },
@@ -84,7 +85,7 @@ func TestValidateCandidate(t *testing.T) {
8485 assert .ErrorContains (t , p .Err , tc .invalid )
8586 default :
8687 assert .NilError (t , err )
87- assert .Equal (t , NamePrefix + p .Name , goodPluginName )
88+ assert .Equal (t , metadata . NamePrefix + p .Name , goodPluginName )
8889 assert .Equal (t , p .SchemaVersion , "0.1.0" )
8990 assert .Equal (t , p .Vendor , "e2e-testing" )
9091 }
0 commit comments