(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | } |
nothing calls this directly
no test coverage detected