MCPcopy Index your code
hub / github.com/helm/helm / TestLoadMetadataLegacy

Function TestLoadMetadataLegacy

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

Source from the content-addressed store, hash-verified

261}
262
263func TestLoadMetadataLegacy(t *testing.T) {
264 testCases := map[string]struct {
265 yaml string
266 expectError bool
267 errorContains string
268 expectedName string
269 logNote string
270 }{
271 "capital name field": {
272 yaml: `Name: my-plugin
273version: 1.0.0
274usage: test plugin
275description: test description
276command: echo test`,
277 expectError: true,
278 errorContains: `invalid plugin name "": must contain only a-z, A-Z, 0-9, _ and -`,
279 // Legacy plugins: No strict unmarshalling (backwards compatibility)
280 // YAML decoder silently ignores "Name:", then validation catches empty name
281 logNote: "NOTE: V1 plugins use strict unmarshalling and would get: yaml: field Name not found",
282 },
283 "correct name field": {
284 yaml: `name: my-plugin
285version: 1.0.0
286usage: test plugin
287description: test description
288command: echo test`,
289 expectError: false,
290 expectedName: "my-plugin",
291 },
292 }
293
294 for name, tc := range testCases {
295 t.Run(name, func(t *testing.T) {
296 m, err := loadMetadataLegacy([]byte(tc.yaml))
297
298 if tc.expectError {
299 require.Error(t, err)
300 assert.Contains(t, err.Error(), tc.errorContains)
301 t.Logf("Legacy error (validation catches empty name): %v", err)
302 if tc.logNote != "" {
303 t.Log(tc.logNote)
304 }
305 } else {
306 require.NoError(t, err)
307 assert.Equal(t, tc.expectedName, m.Name)
308 }
309 })
310 }
311}
312
313func TestLoadMetadataV1(t *testing.T) {
314 testCases := map[string]struct {

Callers

nothing calls this directly

Calls 4

loadMetadataLegacyFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…