MCPcopy
hub / github.com/helm/helm / TestMetadataValidateVersion

Function TestMetadataValidateVersion

internal/plugin/metadata_test.go:77–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

75}
76
77func TestMetadataValidateVersion(t *testing.T) {
78 testValid := map[string]struct {
79 version string
80 }{
81 "valid semver": {version: "1.0.0"},
82 "valid semver with prerelease": {version: "1.2.3-alpha.1+build.123"},
83 "empty version": {version: ""},
84 }
85
86 testInvalid := map[string]struct {
87 version string
88 }{
89 "valid semver with v prefix": {version: "v1.0.0"},
90 "path traversal": {version: "../../../../tmp/evil"},
91 "path traversal in version": {version: "1.0.0/../../etc"},
92 "not a version": {version: "not-a-version"},
93 }
94
95 for name, tc := range testValid {
96 t.Run(name, func(t *testing.T) {
97 m := mockSubprocessCLIPlugin(t, "testplugin")
98 m.metadata.Version = tc.version
99 err := m.Metadata().Validate()
100 assert.NoError(t, err)
101 })
102 }
103
104 for name, tc := range testInvalid {
105 t.Run(name, func(t *testing.T) {
106 m := mockSubprocessCLIPlugin(t, "testplugin")
107 m.metadata.Version = tc.version
108 err := m.Metadata().Validate()
109 assert.ErrorContains(t, err, "invalid plugin version")
110 })
111 }
112}
113
114func TestMetadataValidateMultipleErrors(t *testing.T) {
115 // Create metadata with multiple validation issues

Callers

nothing calls this directly

Calls 4

mockSubprocessCLIPluginFunction · 0.85
RunMethod · 0.65
ValidateMethod · 0.65
MetadataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…