Skip to content

Conversation

@arturaslcast
Copy link
Contributor

the controller constructor takes dependencies which are only used to initialize the default actions even if those are not used anywhere else in the implementation. Extract the actions to simplify the controller constructor and inject them instead.

@arturaslcast arturaslcast requested a review from a team as a code owner December 29, 2025 14:16
}

func (h ActionHandlers) Close() error {
return h[reflect.TypeOf(&castai.ActionCreateEvent{})].(*CreateEventHandler).Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can panic, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really when used with the constructor, but this is mostly copy & paste from the existing place

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, maybe we should make it not panic even in this case, minor change

for k := range s.actionHandlers {
s.actionHandlers[k] = handler
testActionHandlers := map[reflect.Type]actions.ActionHandler{
reflect.TypeOf(&castai.ActionDeleteNode{}): handler,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to initialize them all with mock handler, correct? Does this mean we only test these 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, only 3 action types are actually tested here. I'd argue if only fake actions should be used instead as it's mostly to test if the controller implementation works correctly

@arturaslcast arturaslcast merged commit 5f2a170 into main Dec 29, 2025
3 checks passed
@arturaslcast arturaslcast deleted the arturasl/separate-actions branch December 29, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants