@@ -149,6 +149,8 @@ var _ = Describe("notifications", func() {
149149 color := notifications .ColorInt
150150 data := notifications .GetTemplateData (command )
151151 title := url .QueryEscape (data .Title )
152+ username := "containrrrbot"
153+ iconURL := "https://containrrr.dev/watchtower-sq180.png"
152154 expected := fmt .Sprintf ("discord://%s@%s?color=0x%x&colordebug=0x0&colorerror=0x0&colorinfo=0x0&colorwarn=0x0&title=%s&username=watchtower" , token , channel , color , title )
153155 buildArgs := func (url string ) []string {
154156 return []string {
@@ -167,6 +169,27 @@ var _ = Describe("notifications", func() {
167169 hookURL := fmt .Sprintf ("https://%s/api/webhooks/%s/%s/slack" , "discordapp.com" , channel , token )
168170 testURL (buildArgs (hookURL ), expected , time .Duration (0 ))
169171 })
172+ When ("icon URL and username are specified" , func () {
173+ It ("should return the expected URL" , func () {
174+ hookURL := fmt .Sprintf ("https://%s/api/webhooks/%s/%s/slack" , "discord.com" , channel , token )
175+ expectedOutput := fmt .Sprintf ("discord://%s@%s?avatar=%s&color=0x%x&colordebug=0x0&colorerror=0x0&colorinfo=0x0&colorwarn=0x0&title=%s&username=%s" , token , channel , url .QueryEscape (iconURL ), color , title , username )
176+ expectedDelay := time .Duration (7 ) * time .Second
177+ args := []string {
178+ "--notifications" ,
179+ "slack" ,
180+ "--notification-slack-hook-url" ,
181+ hookURL ,
182+ "--notification-slack-identifier" ,
183+ username ,
184+ "--notification-slack-icon-url" ,
185+ iconURL ,
186+ "--notifications-delay" ,
187+ fmt .Sprint (expectedDelay .Seconds ()),
188+ }
189+
190+ testURL (args , expectedOutput , expectedDelay )
191+ })
192+ })
170193 })
171194 When ("converting a slack service config into a shoutrrr url" , func () {
172195 command := cmd .NewRootCommand ()
0 commit comments