From 04fc59f538a6d879af09db8e36a85a17b5d15d28 Mon Sep 17 00:00:00 2001 From: Stefan Benz <46600784+stebenz@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:47:38 +0200 Subject: [PATCH] fix: empty custom text changes push no events (#8054) # Which Problems Are Solved If there is no custom text given, the call ends in an internal error as no events have to be pushed. # How the Problems Are Solved If no events have to be pushed, no trying to push an empty list of events. # Additional Changes No additional changes. # Additional Context Closes #6954 --- internal/command/instance_custom_login_text.go | 3 +++ internal/command/instance_custom_login_text_test.go | 1 - internal/command/instance_custom_message_text.go | 3 +++ internal/command/instance_custom_message_text_test.go | 1 - internal/command/org_custom_login_text.go | 3 +++ internal/command/org_custom_login_text_test.go | 1 - internal/command/org_custom_message_text.go | 3 +++ internal/command/org_custom_message_text_test.go | 1 - 8 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/command/instance_custom_login_text.go b/internal/command/instance_custom_login_text.go index ca86a48290..a132b2d20a 100644 --- a/internal/command/instance_custom_login_text.go +++ b/internal/command/instance_custom_login_text.go @@ -21,6 +21,9 @@ func (c *Commands) SetCustomInstanceLoginText(ctx context.Context, loginText *do if err != nil { return nil, err } + if len(events) == 0 { + return writeModelToObjectDetails(&existingMailText.WriteModel), nil + } pushedEvents, err := c.eventstore.Push(ctx, events...) if err != nil { return nil, err diff --git a/internal/command/instance_custom_login_text_test.go b/internal/command/instance_custom_login_text_test.go index abdaf7307d..57efbf43d7 100644 --- a/internal/command/instance_custom_login_text_test.go +++ b/internal/command/instance_custom_login_text_test.go @@ -38,7 +38,6 @@ func TestCommandSide_SetCustomIAMLoginText(t *testing.T) { eventstore: eventstoreExpect( t, expectFilter(), - expectPush(), ), }, args: args{ diff --git a/internal/command/instance_custom_message_text.go b/internal/command/instance_custom_message_text.go index 03c073e4d3..f8b4ed3178 100644 --- a/internal/command/instance_custom_message_text.go +++ b/internal/command/instance_custom_message_text.go @@ -21,6 +21,9 @@ func (c *Commands) SetDefaultMessageText(ctx context.Context, instanceID string, if err != nil { return nil, err } + if len(events) == 0 { + return writeModelToObjectDetails(&existingMessageText.WriteModel), nil + } pushedEvents, err := c.eventstore.Push(ctx, events...) if err != nil { return nil, err diff --git a/internal/command/instance_custom_message_text_test.go b/internal/command/instance_custom_message_text_test.go index edb330c6a3..76f463ae02 100644 --- a/internal/command/instance_custom_message_text_test.go +++ b/internal/command/instance_custom_message_text_test.go @@ -54,7 +54,6 @@ func TestCommandSide_SetDefaultMessageText(t *testing.T) { eventstore: eventstoreExpect( t, expectFilter(), - expectPush(), ), }, args: args{ diff --git a/internal/command/org_custom_login_text.go b/internal/command/org_custom_login_text.go index b3d52c669a..1f906972bf 100644 --- a/internal/command/org_custom_login_text.go +++ b/internal/command/org_custom_login_text.go @@ -23,6 +23,9 @@ func (c *Commands) SetOrgLoginText(ctx context.Context, resourceOwner string, lo if err != nil { return nil, err } + if len(events) == 0 { + return writeModelToObjectDetails(&existingLoginText.WriteModel), nil + } pushedEvents, err := c.eventstore.Push(ctx, events...) if err != nil { return nil, err diff --git a/internal/command/org_custom_login_text_test.go b/internal/command/org_custom_login_text_test.go index 0411a533a4..81f7c308d3 100644 --- a/internal/command/org_custom_login_text_test.go +++ b/internal/command/org_custom_login_text_test.go @@ -56,7 +56,6 @@ func TestCommandSide_SetCustomOrgLoginText(t *testing.T) { eventstore: eventstoreExpect( t, expectFilter(), - expectPush(), ), }, args: args{ diff --git a/internal/command/org_custom_message_text.go b/internal/command/org_custom_message_text.go index cd9fc2da9c..266b502090 100644 --- a/internal/command/org_custom_message_text.go +++ b/internal/command/org_custom_message_text.go @@ -23,6 +23,9 @@ func (c *Commands) SetOrgMessageText(ctx context.Context, resourceOwner string, if err != nil { return nil, err } + if len(events) == 0 { + return writeModelToObjectDetails(&existingMessageText.WriteModel), nil + } pushedEvents, err := c.eventstore.Push(ctx, events...) if err != nil { return nil, err diff --git a/internal/command/org_custom_message_text_test.go b/internal/command/org_custom_message_text_test.go index 424a887794..ffa8d87aed 100644 --- a/internal/command/org_custom_message_text_test.go +++ b/internal/command/org_custom_message_text_test.go @@ -67,7 +67,6 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) { eventstore: eventstoreExpect( t, expectFilter(), - expectPush(), ), }, args: args{