MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestPluginRegistry_NodeActions

Function TestPluginRegistry_NodeActions

internal/ui/components/plugins_test.go:12–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestPluginRegistry_NodeActions(t *testing.T) {
13 registry := newPluginRegistry()
14
15 action := NodeAction{
16 ID: "test-action",
17 Label: "Test",
18 Shortcut: 't',
19 IsAvailable: func(node *api.Node) bool {
20 return node != nil
21 },
22 Handler: func(ctx context.Context, app *App, node *api.Node) error {
23 return nil
24 },
25 }
26
27 registry.RegisterNodeAction(action)
28
29 actions := registry.NodeActions()
30 require.Len(t, actions, 1)
31 require.Equal(t, "test-action", actions[0].ID)
32
33 available := registry.NodeActionsForNode(&api.Node{})
34 require.Len(t, available, 1)
35
36 unavailable := registry.NodeActionsForNode(nil)
37 require.Len(t, unavailable, 0)
38}

Callers

nothing calls this directly

Calls 4

newPluginRegistryFunction · 0.85
NodeActionsMethod · 0.80
NodeActionsForNodeMethod · 0.80
RegisterNodeActionMethod · 0.65

Tested by

no test coverage detected