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

Function mockSubprocessCLIPluginErrorExit

internal/plugin/runtime_subprocess_test.go:32–67  ·  view source on GitHub ↗
(t *testing.T, pluginName string, exitCode uint8)

Source from the content-addressed store, hash-verified

30)
31
32func mockSubprocessCLIPluginErrorExit(t *testing.T, pluginName string, exitCode uint8) *SubprocessPluginRuntime {
33 t.Helper()
34
35 rc := RuntimeConfigSubprocess{
36 PlatformCommand: []PlatformCommand{
37 {Command: "sh", Args: []string{"-c", fmt.Sprintf("echo \"mock plugin $@\"; exit %d", exitCode)}},
38 },
39 }
40
41 pluginDir := t.TempDir()
42
43 md := Metadata{
44 Name: pluginName,
45 Version: "0.1.2",
46 Type: "cli/v1",
47 APIVersion: "v1",
48 Runtime: "subprocess",
49 Config: &schema.ConfigCLIV1{
50 Usage: "Mock plugin",
51 ShortHelp: "Mock plugin",
52 LongHelp: "Mock plugin for testing",
53 IgnoreFlags: false,
54 },
55 RuntimeConfig: &rc,
56 }
57
58 data, err := yaml.Marshal(md)
59 require.NoError(t, err)
60 os.WriteFile(filepath.Join(pluginDir, "plugin.yaml"), data, 0o644)
61
62 return &SubprocessPluginRuntime{
63 metadata: md,
64 pluginDir: pluginDir,
65 RuntimeConfig: rc,
66 }
67}
68
69func TestSubprocessPluginRuntime(t *testing.T) {
70 p := mockSubprocessCLIPluginErrorExit(t, "foo", 56)

Callers 1

Calls 2

HelperMethod · 0.80
WriteFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…