MCPcopy
hub / github.com/helm/helm / TestPluginPackageSigningFailure

Function TestPluginPackageSigningFailure

pkg/cmd/plugin_package_test.go:130–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestPluginPackageSigningFailure(t *testing.T) {
131 // Create a test plugin directory
132 tempDir := t.TempDir()
133 pluginDir := filepath.Join(tempDir, "test-plugin")
134 if err := os.MkdirAll(pluginDir, 0755); err != nil {
135 t.Fatal(err)
136 }
137
138 // Create a plugin.yaml file
139 if err := os.WriteFile(filepath.Join(pluginDir, "plugin.yaml"), []byte(testPluginYAML), 0644); err != nil {
140 t.Fatal(err)
141 }
142
143 // Create package options with sign flag but invalid keyring
144 o := &pluginPackageOptions{
145 sign: true,
146 keyring: "/non/existent/keyring", // This will cause signing to fail
147 pluginPath: pluginDir,
148 destination: tempDir,
149 }
150
151 // Run the package command
152 out := &bytes.Buffer{}
153 err := o.run(out)
154
155 // Should get an error
156 if err == nil {
157 t.Error("expected error when signing fails, got nil")
158 }
159
160 // Check that no tarball was created
161 tarballPath := filepath.Join(tempDir, "test-plugin.tgz")
162 if _, err := os.Stat(tarballPath); !os.IsNotExist(err) {
163 t.Error("tarball should not exist when signing fails")
164 }
165
166 // Output should not contain success message
167 if bytes.Contains(out.Bytes(), []byte("Successfully packaged")) {
168 t.Error("should not print success message when signing fails")
169 }
170}

Callers

nothing calls this directly

Calls 5

runMethod · 0.95
FatalMethod · 0.80
ContainsMethod · 0.80
WriteFileMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…