From 56bf8364cdf9c5c1a4b859a5418c4b80ea64c9c0 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Tue, 20 Oct 2020 22:51:58 +0200 Subject: [PATCH] test: add test for InitializeActionHandler Signed-off-by: Mark Sagi-Kazar --- common/actions_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/common/actions_test.go b/common/actions_test.go index e65c0e87..e35d0b5a 100644 --- a/common/actions_test.go +++ b/common/actions_test.go @@ -179,3 +179,27 @@ func TestPreDeleteAction(t *testing.T) { Config.Actions = actionsCopy } + +type actionHandlerStub struct { + called bool +} + +func (h *actionHandlerStub) Handle(notification ActionNotification) error { + h.called = true + + return nil +} + +func TestInitializeActionHandler(t *testing.T) { + handler := &actionHandlerStub{} + + InitializeActionHandler(handler) + t.Cleanup(func() { + InitializeActionHandler(defaultActionHandler{}) + }) + + err := actionHandler.Handle(ActionNotification{}) + + assert.NoError(t, err) + assert.True(t, handler.called) +}