Skip to content

Commit d38e52b

Browse files
pikselsimskij
andauthored
fix: merge artifacts and broken shoutrrr tests (#929)
* test: add missing container test suite * fix broken tests * fix: remove duplicate merge artifact Co-authored-by: Simon Aronsson <[email protected]>
1 parent dff8378 commit d38e52b

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/docker/docker v0.0.0-20190404075923-dbe4a30928d4
2424
github.com/docker/docker-credential-helpers v0.6.1 // indirect
2525
github.com/docker/go v1.5.1-1 // indirect
26-
github.com/docker/go-connections v0.4.0 // indirect
26+
github.com/docker/go-connections v0.4.0
2727
github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect
2828
github.com/docker/go-units v0.3.3 // indirect
2929
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect

internal/actions/mocks/container.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/containrrr/watchtower/pkg/container"
55
"github.com/docker/docker/api/types"
66
container2 "github.com/docker/docker/api/types/container"
7+
"github.com/docker/go-connections/nat"
78
"time"
89
)
910

@@ -19,6 +20,7 @@ func CreateMockContainer(id string, name string, image string, created time.Time
1920
Config: &container2.Config{
2021
Image: image,
2122
Labels: make(map[string]string),
23+
ExposedPorts: map[nat.Port]struct{}{},
2224
},
2325
}
2426
return *container.NewContainer(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package container_test
2+
3+
import (
4+
"testing"
5+
6+
. "github.com/onsi/ginkgo"
7+
. "github.com/onsi/gomega"
8+
)
9+
10+
func TestContainer(t *testing.T) {
11+
RegisterFailHandler(Fail)
12+
RunSpecs(t, "Container Suite")
13+
}

pkg/metrics/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ func (metrics *Metrics) QueueIsEmpty() bool {
2929
return len(metrics.channel) == 0
3030
}
3131

32-
// QueueIsEmpty checks whether any messages are enqueued in the channel
33-
func (metrics *Metrics) QueueIsEmpty() bool {
34-
return len(metrics.channel) == 0
35-
}
36-
3732
// Register registers metrics for an executed scan
3833
func (metrics *Metrics) Register(metric *Metric) {
3934
metrics.channel <- metric

pkg/notifications/notifier_test.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var _ = Describe("notifications", func() {
4747
token := "abvsihdbau"
4848
color := notifications.ColorInt
4949
title := url.QueryEscape(notifications.GetTitle())
50-
expected := fmt.Sprintf("discord://%s@%s?avatar=&color=0x%x&colordebug=0x0&colorerror=0x0&colorinfo=0x0&colorwarn=0x0&splitlines=Yes&title=%s&username=watchtower", token, channel, color, title)
50+
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)
5151
buildArgs := func(url string) []string {
5252
return []string{
5353
"--notifications",
@@ -101,7 +101,7 @@ var _ = Describe("notifications", func() {
101101
host := "shoutrrr.local"
102102
title := url.QueryEscape(notifications.GetTitle())
103103

104-
expectedOutput := fmt.Sprintf("gotify://%s/%s?disabletls=No&priority=0&title=%s", host, token, title)
104+
expectedOutput := fmt.Sprintf("gotify://%s/%s?title=%s", host, token, title)
105105

106106
args := []string{
107107
"--notification-gotify-url",
@@ -128,7 +128,7 @@ var _ = Describe("notifications", func() {
128128
title := url.QueryEscape(notifications.GetTitle())
129129

130130
hookURL := fmt.Sprintf("https://outlook.office.com/webhook/%s/IncomingWebhook/%s/%s", tokenA, tokenB, tokenC)
131-
expectedOutput := fmt.Sprintf("teams://%s/%s/%s?color=%s&host=outlook.office.com&title=%s", tokenA, tokenB, tokenC, color, title)
131+
expectedOutput := fmt.Sprintf("teams://%s/%s/%s?color=%s&title=%s", tokenA, tokenB, tokenC, color, title)
132132

133133
args := []string{
134134
"--notification-msteams-hook",
@@ -147,10 +147,18 @@ var _ = Describe("notifications", func() {
147147
When("converting an email service config into a shoutrrr url", func() {
148148
It("should set the from address in the URL", func() {
149149
fromAddress := "[email protected]"
150-
expectedOutput := buildExpectedURL("", "", "", 25, fromAddress, "", "None")
150+
expectedOutput := buildExpectedURL("containrrrbot", "secret-password", "mail.containrrr.dev", 25, fromAddress, "[email protected]", "Plain")
151151
args := []string{
152152
"--notification-email-from",
153153
fromAddress,
154+
"--notification-email-to",
155+
156+
"--notification-email-server-user",
157+
"containrrrbot",
158+
"--notification-email-server-password",
159+
"secret-password",
160+
"--notification-email-server",
161+
"mail.containrrr.dev",
154162
}
155163
testURL(builderFn, args, expectedOutput)
156164
})
@@ -159,13 +167,19 @@ var _ = Describe("notifications", func() {
159167

160168
fromAddress := "[email protected]"
161169
toAddress := "[email protected]"
162-
expectedOutput := buildExpectedURL("", "", "", 25, fromAddress, toAddress, "None")
170+
expectedOutput := buildExpectedURL("containrrrbot", "secret-password", "mail.containrrr.dev", 25, fromAddress, toAddress, "Plain")
163171

164172
args := []string{
165173
"--notification-email-from",
166174
fromAddress,
167175
"--notification-email-to",
168176
toAddress,
177+
"--notification-email-server-user",
178+
"containrrrbot",
179+
"--notification-email-server-password",
180+
"secret-password",
181+
"--notification-email-server",
182+
"mail.containrrr.dev",
169183
}
170184

171185
testURL(builderFn, args, expectedOutput)
@@ -180,7 +194,7 @@ func buildExpectedURL(username string, password string, host string, port int, f
180194

181195
subject := fmt.Sprintf("Watchtower updates on %s", hostname)
182196

183-
var template = "smtp://%s:%s@%s:%d/?auth=%s&encryption=Auto&fromaddress=%s&fromname=Watchtower&starttls=Yes&subject=%s&toaddresses=%s&usehtml=No"
197+
var template = "smtp://%s:%s@%s:%d/?auth=%s&fromaddress=%s&fromname=Watchtower&subject=%s&toaddresses=%s"
184198
return fmt.Sprintf(template,
185199
url.QueryEscape(username),
186200
url.QueryEscape(password),

0 commit comments

Comments
 (0)