|
|
|
@ -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"
|
|
|
|
|
|
|
|
|
|
When("icon URL 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, url.QueryEscape(iconURL), title)
|
|
|
|
|
|
|
|
|
|
args := []string{
|
|
|
|
|
"--notifications",
|
|
|
|
|
"slack",
|
|
|
|
|
"--notification-slack-hook-url",
|
|
|
|
|
hookURL,
|
|
|
|
|
"--notification-slack-identifier",
|
|
|
|
|
username,
|
|
|
|
|
"--notification-slack-icon-url",
|
|
|
|
|
iconURL,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
testURL(args, expectedOutput)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
It("should return the expected URL", func() {
|
|
|
|
|
command := cmd.NewRootCommand()
|
|
|
|
|
flags.RegisterNotificationFlags(command)
|
|
|
|
|
|
|
|
|
|
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://%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,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|