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

Function TestListPluginsIsSorted

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

Source from the content-addressed store, hash-verified

133}
134
135func TestListPluginsIsSorted(t *testing.T) {
136 dir := fs.NewDir(t, t.Name(),
137 fs.WithFile("docker-bbb", `
138#!/bin/sh
139echo '{"SchemaVersion":"0.1.0"}'`, fs.WithMode(0o777)),
140 fs.WithFile("docker-aaa", `
141#!/bin/sh
142echo '{"SchemaVersion":"0.1.0"}'`, fs.WithMode(0o777)),
143 )
144 defer dir.Remove()
145
146 cli := test.NewFakeCli(nil)
147 cli.SetConfigFile(&configfile.ConfigFile{CLIPluginsExtraDirs: []string{dir.Path()}})
148
149 plugins, err := ListPlugins(cli, &cobra.Command{})
150 assert.NilError(t, err)
151
152 // We're only interested in the plugins we created for testing this, and only
153 // if they appear in the expected order
154 var names []string
155 for _, p := range plugins {
156 if p.Name == "aaa" || p.Name == "bbb" {
157 names = append(names, p.Name)
158 }
159 }
160 assert.DeepEqual(t, names, []string{"aaa", "bbb"})
161}
162
163func TestErrPluginNotFound(t *testing.T) {
164 var err error = errPluginNotFound("test")

Callers

nothing calls this directly

Calls 5

SetConfigFileMethod · 0.95
ListPluginsFunction · 0.85
RemoveMethod · 0.65
PathMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…