MCPcopy
hub / github.com/helm/helm / TestLoadMetadataV1

Function TestLoadMetadataV1

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

Source from the content-addressed store, hash-verified

311}
312
313func TestLoadMetadataV1(t *testing.T) {
314 testCases := map[string]struct {
315 yaml string
316 expectError bool
317 errorContains string
318 expectedName string
319 }{
320 "capital name field": {
321 yaml: `apiVersion: v1
322Name: my-plugin
323type: cli/v1
324runtime: subprocess
325`,
326 expectError: true,
327 errorContains: "field Name not found in type plugin.MetadataV1",
328 },
329 "correct name field": {
330 yaml: `apiVersion: v1
331name: my-plugin
332version: 1.0.0
333type: cli/v1
334runtime: subprocess
335`,
336 expectError: false,
337 expectedName: "my-plugin",
338 },
339 }
340
341 for name, tc := range testCases {
342 t.Run(name, func(t *testing.T) {
343 m, err := loadMetadataV1([]byte(tc.yaml))
344
345 if tc.expectError {
346 require.Error(t, err)
347 assert.Contains(t, err.Error(), tc.errorContains)
348 t.Logf("V1 error (strict unmarshalling): %v", err)
349 } else {
350 require.NoError(t, err)
351 assert.Equal(t, tc.expectedName, m.Name)
352 }
353 })
354 }
355}

Callers

nothing calls this directly

Calls 4

loadMetadataV1Function · 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…