(t *testing.T, pluginName string, exitCode uint8)
| 30 | ) |
| 31 | |
| 32 | func 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 | |
| 69 | func TestSubprocessPluginRuntime(t *testing.T) { |
| 70 | p := mockSubprocessCLIPluginErrorExit(t, "foo", 56) |
no test coverage detected
searching dependent graphs…