From 1e89fea274e373776e689a2aef7d9f51b3fafb0c Mon Sep 17 00:00:00 2001 From: Michal Rudowicz Date: Sun, 18 Feb 2024 12:38:24 +0100 Subject: [PATCH] Small simplifcation --- main.go | 2 +- sender_worker_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index b27e41b..0263e09 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,7 @@ func (self TgSender) Send(msg GenericMessage) error { } func sendTgMessage(tgEvents chan GenericMessage, msg string, chatId int64) { - tgEvents <- GenericMessage{TgChatId{chatId}, []MsgContent{MsgContent{msg}}} + tgEvents <- GenericMessage{TgChatId{chatId}, []MsgContent{{msg}}} } type RealSleeper struct { diff --git a/sender_worker_test.go b/sender_worker_test.go index 3c87e5b..eff800f 100644 --- a/sender_worker_test.go +++ b/sender_worker_test.go @@ -37,18 +37,18 @@ func TestMessageThrottling(t *testing.T) { mockSleeper := MockSleeper{nil, 0} Consume(SendToTg(tgSenderWorker(testEvents, &wg, &mockSleeper, log.New(io.Discard, "", log.Ltime)), &mockSender, &wg, log.New(io.Discard, "", log.Ltime))) - testEvents <- GenericMessage{TgChatId{123}, []MsgContent{MsgContent{"test1"}}} - testEvents <- GenericMessage{TgChatId{124}, []MsgContent{MsgContent{"test3"}}} - testEvents <- GenericMessage{TgChatId{123}, []MsgContent{MsgContent{"test2"}}} - testEvents <- GenericMessage{TgChatId{124}, []MsgContent{MsgContent{"test4"}}} + testEvents <- GenericMessage{TgChatId{123}, []MsgContent{{"test1"}}} + testEvents <- GenericMessage{TgChatId{124}, []MsgContent{{"test3"}}} + testEvents <- GenericMessage{TgChatId{123}, []MsgContent{{"test2"}}} + testEvents <- GenericMessage{TgChatId{124}, []MsgContent{{"test4"}}} assert.Equal(t, 1, mockSleeper.callCount) *mockSleeper.ch <- nil assert.Equal(t, 1, mockSleeper.callCount) - testEvents <- GenericMessage{TgChatId{123}, []MsgContent{MsgContent{"test5"}}} + testEvents <- GenericMessage{TgChatId{123}, []MsgContent{{"test5"}}} close(testEvents) wg.Wait() assert.Equal(t, 2, mockSleeper.callCount) assert.Len(t, mockSender.messages, 3) - assert.Contains(t, mockSender.messages, GenericMessage{TgChatId{123}, []MsgContent{MsgContent{"test1"}, MsgContent{"test2"}}}) + assert.Contains(t, mockSender.messages, GenericMessage{TgChatId{123}, []MsgContent{{"test1"}, {"test2"}}}) }