Repository: containrrr/watchtower
Pull request #929 (2021-04-24 12:54:03)

Fix broken tests

codecov[bot]: # [Codecov](https://codecov.io/gh/containrrr/watchtower/pull/929?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr) Report
> Merging [#929](https://codecov.io/gh/containrrr/watchtower/pull/929?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr) (d35eae8) into [main](https://codecov.io/gh/containrrr/watchtower/commit/b4cf17d33fc361988201a503d3e32a902c5d29da?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr) (b4cf17d) will **increase** coverage by `6.53%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/containrrr/watchtower/pull/929/graphs/tree.svg?width=650&height=150&src=pr&token=8pxWgB380Y&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr)](https://codecov.io/gh/containrrr/watchtower/pull/929?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr)

```diff
@@            Coverage Diff             @@
##             main     #929      +/-   ##
==========================================
+ Coverage   40.14%   46.68%   +6.53%     
==========================================
  Files          25       25              
  Lines        1415     1416       +1     
==========================================
+ Hits          568      661      +93     
+ Misses        785      687      -98     
- Partials       62       68       +6     
```


| [Impacted Files](https://codecov.io/gh/containrrr/watchtower/pull/929?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr) | Coverage Δ | |
|---|---|---|
| [pkg/notifications/shoutrrr.go](https://codecov.io/gh/containrrr/watchtower/pull/929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr#diff-cGtnL25vdGlmaWNhdGlvbnMvc2hvdXRycnIuZ28=) | `73.43% <100.00%> (+0.42%)` | :arrow_up: |
| [pkg/notifications/email.go](https://codecov.io/gh/containrrr/watchtower/pull/929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr#diff-cGtnL25vdGlmaWNhdGlvbnMvZW1haWwuZ28=) | `90.90% <0.00%> (+4.54%)` | :arrow_up: |
| [pkg/container/client.go](https://codecov.io/gh/containrrr/watchtower/pull/929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr#diff-cGtnL2NvbnRhaW5lci9jbGllbnQuZ28=) | `18.45% <0.00%> (+18.45%)` | :arrow_up: |
| [pkg/container/container.go](https://codecov.io/gh/containrrr/watchtower/pull/929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr#diff-cGtnL2NvbnRhaW5lci9jb250YWluZXIuZ28=) | `36.70% <0.00%> (+36.70%)` | :arrow_up: |
| [pkg/container/metadata.go](https://codecov.io/gh/containrrr/watchtower/pull/929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr#diff-cGtnL2NvbnRhaW5lci9tZXRhZGF0YS5nbw==) | `63.63% <0.00%> (+63.63%)` | :arrow_up: |
| [pkg/container/util.go](https://codecov.io/gh/containrrr/watchtower/pull/929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr#diff-cGtnL2NvbnRhaW5lci91dGlsLmdv) | `100.00% <0.00%> (+100.00%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/containrrr/watchtower/pull/929?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/containrrr/watchtower/pull/929?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr). Last update [dff8378...d35eae8](https://codecov.io/gh/containrrr/watchtower/pull/929?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containrrr).


Patch:
diff --git a/go.mod b/go.mod
index 35a2c24..225915b 100644
--- a/go.mod
+++ b/go.mod
@@ -23,7 +23,7 @@ require (
 	github.com/docker/docker v0.0.0-20190404075923-dbe4a30928d4
 	github.com/docker/docker-credential-helpers v0.6.1 // indirect
 	github.com/docker/go v1.5.1-1 // indirect
-	github.com/docker/go-connections v0.4.0 // indirect
+	github.com/docker/go-connections v0.4.0
 	github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect
 	github.com/docker/go-units v0.3.3 // indirect
 	github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
diff --git a/internal/actions/mocks/container.go b/internal/actions/mocks/container.go
index 1db8652..a4ded79 100644
--- a/internal/actions/mocks/container.go
+++ b/internal/actions/mocks/container.go
@@ -4,6 +4,7 @@ import (
 	"github.com/containrrr/watchtower/pkg/container"
 	"github.com/docker/docker/api/types"
 	container2 "github.com/docker/docker/api/types/container"
+	"github.com/docker/go-connections/nat"
 	"time"
 )
 
@@ -19,6 +20,7 @@ func CreateMockContainer(id string, name string, image string, created time.Time
 		Config: &container2.Config{
 			Image:  image,
 			Labels: make(map[string]string),
+			ExposedPorts: map[nat.Port]struct{}{},
 		},
 	}
 	return *container.NewContainer(
diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go
index 91be2e6..d8761ba 100644
--- a/pkg/metrics/metrics.go
+++ b/pkg/metrics/metrics.go
@@ -29,11 +29,6 @@ func (metrics *Metrics) QueueIsEmpty() bool {
 	return len(metrics.channel) == 0
 }
 
-// QueueIsEmpty checks whether any messages are enqueued in the channel
-func (metrics *Metrics) QueueIsEmpty() bool {
-	return len(metrics.channel) == 0
-}
-
 // Register registers metrics for an executed scan
 func (metrics *Metrics) Register(metric *Metric) {
 	metrics.channel <- metric


Test patch:
diff --git a/pkg/container/container_suite_test.go b/pkg/container/container_suite_test.go
new file mode 100644
index 0000000..292a008
--- /dev/null
+++ b/pkg/container/container_suite_test.go
@@ -0,0 +1,13 @@
+package container_test
+
+import (
+	"testing"
+
+	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/gomega"
+)
+
+func TestContainer(t *testing.T) {
+	RegisterFailHandler(Fail)
+	RunSpecs(t, "Container Suite")
+}
diff --git a/pkg/notifications/notifier_test.go b/pkg/notifications/notifier_test.go
index ecd228f..ba6657a 100644
--- a/pkg/notifications/notifier_test.go
+++ b/pkg/notifications/notifier_test.go
@@ -47,7 +47,7 @@ var _ = Describe("notifications", func() {
 			token := "abvsihdbau"
 			color := notifications.ColorInt
 			title := url.QueryEscape(notifications.GetTitle())
-			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)
+			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)
 			buildArgs := func(url string) []string {
 				return []string{
 					"--notifications",
@@ -101,7 +101,7 @@ var _ = Describe("notifications", func() {
 				host := "shoutrrr.local"
 				title := url.QueryEscape(notifications.GetTitle())
 
-				expectedOutput := fmt.Sprintf("gotify://%s/%s?disabletls=No&priority=0&title=%s", host, token, title)
+				expectedOutput := fmt.Sprintf("gotify://%s/%s?title=%s", host, token, title)
 
 				args := []string{
 					"--notification-gotify-url",
@@ -128,7 +128,7 @@ var _ = Describe("notifications", func() {
 				title := url.QueryEscape(notifications.GetTitle())
 
 				hookURL := fmt.Sprintf("https://outlook.office.com/webhook/%s/IncomingWebhook/%s/%s", tokenA, tokenB, tokenC)
-				expectedOutput := fmt.Sprintf("teams://%s/%s/%s?color=%s&host=outlook.office.com&title=%s", tokenA, tokenB, tokenC, color, title)
+				expectedOutput := fmt.Sprintf("teams://%s/%s/%s?color=%s&title=%s", tokenA, tokenB, tokenC, color, title)
 
 				args := []string{
 					"--notification-msteams-hook",
@@ -147,10 +147,18 @@ var _ = Describe("notifications", func() {
 		When("converting an email service config into a shoutrrr url", func() {
 			It("should set the from address in the URL", func() {
 				fromAddress := "lala@example.com"
-				expectedOutput := buildExpectedURL("", "", "", 25, fromAddress, "", "None")
+				expectedOutput := buildExpectedURL("containrrrbot", "secret-password", "mail.containrrr.dev", 25, fromAddress, "mail@example.com", "Plain")
 				args := []string{
 					"--notification-email-from",
 					fromAddress,
+					"--notification-email-to",
+					"mail@example.com",
+					"--notification-email-server-user",
+					"containrrrbot",
+					"--notification-email-server-password",
+					"secret-password",
+					"--notification-email-server",
+					"mail.containrrr.dev",
 				}
 				testURL(builderFn, args, expectedOutput)
 			})
@@ -159,13 +167,19 @@ var _ = Describe("notifications", func() {
 
 				fromAddress := "sender@example.com"
 				toAddress := "receiver@example.com"
-				expectedOutput := buildExpectedURL("", "", "", 25, fromAddress, toAddress, "None")
+				expectedOutput := buildExpectedURL("containrrrbot", "secret-password", "mail.containrrr.dev", 25, fromAddress, toAddress, "Plain")
 
 				args := []string{
 					"--notification-email-from",
 					fromAddress,
 					"--notification-email-to",
 					toAddress,
+					"--notification-email-server-user",
+					"containrrrbot",
+					"--notification-email-server-password",
+					"secret-password",
+					"--notification-email-server",
+					"mail.containrrr.dev",
 				}
 
 				testURL(builderFn, args, expectedOutput)
@@ -180,7 +194,7 @@ func buildExpectedURL(username string, password string, host string, port int, f
 
 	subject := fmt.Sprintf("Watchtower updates on %s", hostname)
 
-	var template = "smtp://%s:%s@%s:%d/?auth=%s&encryption=Auto&fromaddress=%s&fromname=Watchtower&starttls=Yes&subject=%s&toaddresses=%s&usehtml=No"
+	var template = "smtp://%s:%s@%s:%d/?auth=%s&fromaddress=%s&fromname=Watchtower&subject=%s&toaddresses=%s"
 	return fmt.Sprintf(template,
 		url.QueryEscape(username),
 		url.QueryEscape(password),