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"}}}) }