diff --git a/server/.golangci.yml b/server/.golangci.yml index 3b33cc05e3f..b7db5d489b7 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -111,7 +111,6 @@ issues: channels/app/team.go|\ channels/app/team_test.go|\ channels/app/upload.go|\ - channels/app/web_broadcast_hooks_test.go|\ channels/app/webhook_test.go|\ channels/jobs/batch_worker_test.go|\ channels/jobs/helper_test.go|\ diff --git a/server/channels/app/web_broadcast_hooks_test.go b/server/channels/app/web_broadcast_hooks_test.go index e667cefd226..cd6469bda77 100644 --- a/server/channels/app/web_broadcast_hooks_test.go +++ b/server/channels/app/web_broadcast_hooks_test.go @@ -27,9 +27,10 @@ func TestAddMentionsHook_Process(t *testing.T) { require.Nil(t, msg.Event().GetData()["mentions"]) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "mentions": model.StringArray{userID}, }) + require.NoError(t, err) assert.Equal(t, `["`+userID+`"]`, msg.Event().GetData()["mentions"]) assert.Nil(t, msg.Event().GetData()["followers"]) @@ -40,9 +41,10 @@ func TestAddMentionsHook_Process(t *testing.T) { require.Nil(t, msg.Event().GetData()["mentions"]) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "mentions": model.StringArray{otherUserID}, }) + require.NoError(t, err) assert.Nil(t, msg.Event().GetData()["mentions"]) }) @@ -63,9 +65,10 @@ func TestAddFollowersHook_Process(t *testing.T) { require.Nil(t, msg.Event().GetData()["followers"]) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "followers": model.StringArray{userID}, }) + require.NoError(t, err) assert.Equal(t, `["`+userID+`"]`, msg.Event().GetData()["followers"]) }) @@ -75,9 +78,10 @@ func TestAddFollowersHook_Process(t *testing.T) { require.Nil(t, msg.Event().GetData()["followers"]) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "followers": model.StringArray{otherUserID}, }) + require.NoError(t, err) assert.Nil(t, msg.Event().GetData()["followers"]) }) @@ -97,11 +101,12 @@ func TestPostedAckHook_Process(t *testing.T) { t.Run("should ack if user is in the list of users to notify", func(t *testing.T) { msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, "")) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "posted_user_id": model.NewId(), "channel_type": model.ChannelTypeOpen, "users": []string{userID}, }) + require.NoError(t, err) assert.True(t, msg.Event().GetData()["should_ack"].(bool)) }) @@ -109,11 +114,12 @@ func TestPostedAckHook_Process(t *testing.T) { t.Run("should not ack if user is not in the list of users to notify", func(t *testing.T) { msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, "")) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "posted_user_id": model.NewId(), "channel_type": model.ChannelTypeOpen, "users": []string{}, }) + require.NoError(t, err) assert.Nil(t, msg.Event().GetData()["should_ack"]) }) @@ -121,11 +127,12 @@ func TestPostedAckHook_Process(t *testing.T) { t.Run("should not ack if you are the user who posted", func(t *testing.T) { msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, "")) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "posted_user_id": userID, "channel_type": model.ChannelTypeOpen, "users": []string{userID}, }) + require.NoError(t, err) assert.Nil(t, msg.Event().GetData()["should_ack"]) }) @@ -133,11 +140,12 @@ func TestPostedAckHook_Process(t *testing.T) { t.Run("should ack if the channel is a DM", func(t *testing.T) { msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, "")) - hook.Process(msg, webConn, map[string]any{ + err := hook.Process(msg, webConn, map[string]any{ "posted_user_id": model.NewId(), "channel_type": model.ChannelTypeDirect, "users": []string{}, }) + require.NoError(t, err) assert.True(t, msg.Event().GetData()["should_ack"].(bool)) }) @@ -151,11 +159,12 @@ func TestPostedAckHook_Process(t *testing.T) { noAckWebConn.Active.Store(true) msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, "")) - hook.Process(msg, noAckWebConn, map[string]any{ + err := hook.Process(msg, noAckWebConn, map[string]any{ "posted_user_id": model.NewId(), "channel_type": model.ChannelTypeDirect, "users": []string{}, }) + require.NoError(t, err) assert.Nil(t, msg.Event().GetData()["should_ack"]) }) @@ -169,11 +178,12 @@ func TestPostedAckHook_Process(t *testing.T) { inactiveWebConn.Active.Store(true) msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, "")) - hook.Process(msg, inactiveWebConn, map[string]any{ + err := hook.Process(msg, inactiveWebConn, map[string]any{ "posted_user_id": model.NewId(), "channel_type": model.ChannelTypeDirect, "users": []string{}, }) + require.NoError(t, err) assert.Nil(t, msg.Event().GetData()["should_ack"]) }) @@ -196,12 +206,15 @@ func TestAddMentionsAndAddFollowersHooks(t *testing.T) { require.Nil(t, originalData["mentions"]) require.Nil(t, originalData["followers"]) - addMentionsHook.Process(msg, webConn, map[string]any{ + err := addMentionsHook.Process(msg, webConn, map[string]any{ "mentions": model.StringArray{userID}, }) - addFollowersHook.Process(msg, webConn, map[string]any{ + require.NoError(t, err) + + err = addFollowersHook.Process(msg, webConn, map[string]any{ "followers": model.StringArray{userID}, }) + require.NoError(t, err) t.Run("should be able to add both mentions and followers to a single event", func(t *testing.T) { assert.Equal(t, `["`+userID+`"]`, msg.Event().GetData()["followers"])