feat(shoutrrr): update to v0.5 (#1055)

* feat(shoutrrr): update to v0.5
* fix slack URL and tests
* add tests for slack icon override
* bump shoutrrr to v0.5.1
This commit is contained in:
nils måsén 2021-09-19 18:05:10 +02:00 committed by GitHub
parent bd74c05614
commit fc31c6eb26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 28 deletions

View file

@ -40,7 +40,7 @@ var _ = Describe("notifications", func() {
token := "abvsihdbau"
color := notifications.ColorInt
title := url.QueryEscape(notifications.GetTitle(command))
expected := fmt.Sprintf("discord://%s@%s?color=0x%x&colordebug=0x0&colorerror=0x0&colorinfo=0x0&colorwarn=0x0&splitlines=Yes&title=%s&username=watchtower", token, channel, color, title)
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)
buildArgs := func(url string) []string {
return []string{
"--notifications",
@ -60,31 +60,56 @@ var _ = Describe("notifications", func() {
})
})
When("converting a slack service config into a shoutrrr url", func() {
command := cmd.NewRootCommand()
flags.RegisterNotificationFlags(command)
username := "containrrrbot"
tokenA := "AAAAAAAAA"
tokenB := "BBBBBBBBB"
tokenC := "123456789123456789123456"
color := url.QueryEscape(notifications.ColorHex)
title := url.QueryEscape(notifications.GetTitle(command))
iconURL := "https://containrrr.dev/watchtower-sq180.png"
iconEmoji := "whale"
It("should return the expected URL", func() {
command := cmd.NewRootCommand()
flags.RegisterNotificationFlags(command)
When("icon URL is specified", func() {
It("should return the expected URL", func() {
username := "containrrrbot"
tokenA := "aaa"
tokenB := "bbb"
tokenC := "ccc"
color := url.QueryEscape(notifications.ColorHex)
title := url.QueryEscape(notifications.GetTitle(command))
hookURL := fmt.Sprintf("https://hooks.slack.com/services/%s/%s/%s", tokenA, tokenB, tokenC)
expectedOutput := fmt.Sprintf("slack://hook:%s-%s-%s@webhook?botname=%s&color=%s&icon=%s&title=%s", tokenA, tokenB, tokenC, username, color, url.QueryEscape(iconURL), title)
hookURL := fmt.Sprintf("https://hooks.slack.com/services/%s/%s/%s", tokenA, tokenB, tokenC)
expectedOutput := fmt.Sprintf("slack://%s@%s/%s/%s?color=%s&title=%s", username, tokenA, tokenB, tokenC, color, title)
args := []string{
"--notifications",
"slack",
"--notification-slack-hook-url",
hookURL,
"--notification-slack-identifier",
username,
"--notification-slack-icon-url",
iconURL,
}
args := []string{
"--notifications",
"slack",
"--notification-slack-hook-url",
hookURL,
"--notification-slack-identifier",
username,
}
testURL(args, expectedOutput)
})
})
testURL(args, expectedOutput)
When("icon emoji is specified", func() {
It("should return the expected URL", func() {
hookURL := fmt.Sprintf("https://hooks.slack.com/services/%s/%s/%s", tokenA, tokenB, tokenC)
expectedOutput := fmt.Sprintf("slack://hook:%s-%s-%s@webhook?botname=%s&color=%s&icon=%s&title=%s", tokenA, tokenB, tokenC, username, color, iconEmoji, title)
args := []string{
"--notifications",
"slack",
"--notification-slack-hook-url",
hookURL,
"--notification-slack-identifier",
username,
"--notification-slack-icon-emoji",
iconEmoji,
}
testURL(args, expectedOutput)
})
})
})
})
@ -208,6 +233,7 @@ func buildExpectedURL(username string, password string, host string, port int, f
}
func testURL(args []string, expectedURL string) {
defer GinkgoRecover()
command := cmd.NewRootCommand()
flags.RegisterNotificationFlags(command)