@@ -2,7 +2,9 @@ package slack_test
22
33import (
44 "errors"
5+ "fmt"
56 "log"
7+ "strings"
68
79 "github.com/containrrr/shoutrrr/internal/testutils"
810 . "github.com/containrrr/shoutrrr/pkg/services/slack"
@@ -163,7 +165,29 @@ var _ = Describe("the slack service", func() {
163165 Expect (payload .IconURL ).To (BeEmpty ())
164166 })
165167 })
166-
168+ When ("when more than 99 lines are being sent" , func () {
169+ It ("should append the exceeding lines to the last attachment" , func () {
170+ config := Config {}
171+ sb := strings.Builder {}
172+ for i := 1 ; i <= 110 ; i ++ {
173+ sb .WriteString (fmt .Sprintf ("Line %d\n " , i ))
174+ }
175+ payload := CreateJSONPayload (& config , sb .String ()).(MessagePayload )
176+ atts := payload .Attachments
177+
178+ fmt .Printf ("\n Lines: %d, Last: %#v\n " , len (atts ), atts [len (atts )- 1 ])
179+
180+ Expect (atts ).To (HaveLen (100 ))
181+ Expect (atts [len (atts )- 1 ].Text ).To (ContainSubstring ("Line 110" ))
182+ })
183+ })
184+ When ("when the last message line ends with a newline" , func () {
185+ It ("should not send an empty attachment" , func () {
186+ payload := CreateJSONPayload (& Config {}, "One\n Two\n Three\n " ).(MessagePayload )
187+ atts := payload .Attachments
188+ Expect (atts [len (atts )- 1 ].Text ).NotTo (BeEmpty ())
189+ })
190+ })
167191 })
168192
169193 Describe ("sending the payload" , func () {
0 commit comments