MCPcopy
hub / github.com/helm/helm / TestLoadDir

Function TestLoadDir

internal/plugin/loader_test.go:64–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestLoadDir(t *testing.T) {
65
66 makeMetadata := func(apiVersion string) Metadata {
67 usage := "hello [params]..."
68 if apiVersion == "legacy" {
69 usage = "" // Legacy plugins don't have Usage field for command syntax
70 }
71 return Metadata{
72 APIVersion: apiVersion,
73 Name: "hello-" + apiVersion,
74 Version: "0.1.0",
75 Type: "cli/v1",
76 Runtime: "subprocess",
77 Config: &schema.ConfigCLIV1{
78 Usage: usage,
79 ShortHelp: "echo hello message",
80 LongHelp: "description",
81 IgnoreFlags: true,
82 },
83 RuntimeConfig: &RuntimeConfigSubprocess{
84 PlatformCommand: []PlatformCommand{
85 {OperatingSystem: "linux", Architecture: "", Command: "sh", Args: []string{"-c", "${HELM_PLUGIN_DIR}/hello.sh"}},
86 {OperatingSystem: "windows", Architecture: "", Command: "pwsh", Args: []string{"-c", "${HELM_PLUGIN_DIR}/hello.ps1"}},
87 },
88 PlatformHooks: map[string][]PlatformCommand{
89 Install: {
90 {OperatingSystem: "linux", Architecture: "", Command: "sh", Args: []string{"-c", "echo \"installing...\""}},
91 {OperatingSystem: "windows", Architecture: "", Command: "pwsh", Args: []string{"-c", "echo \"installing...\""}},
92 },
93 },
94 expandHookArgs: apiVersion == "legacy",
95 },
96 }
97 }
98
99 testCases := map[string]struct {
100 dirname string
101 apiVersion string
102 expect Metadata
103 }{
104 "legacy": {
105 dirname: "testdata/plugdir/good/hello-legacy",
106 apiVersion: "legacy",
107 expect: makeMetadata("legacy"),
108 },
109 "v1": {
110 dirname: "testdata/plugdir/good/hello-v1",
111 apiVersion: "v1",
112 expect: makeMetadata("v1"),
113 },
114 }
115
116 for name, tc := range testCases {
117 t.Run(name, func(t *testing.T) {
118 plug, err := LoadDir(tc.dirname)
119 require.NoError(t, err, "error loading plugin from %s", tc.dirname)
120
121 assert.Equal(t, tc.dirname, plug.Dir())

Callers

nothing calls this directly

Calls 4

LoadDirFunction · 0.70
RunMethod · 0.65
DirMethod · 0.65
MetadataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…