You've already forked watchtower
							
							
				mirror of
				https://github.com/containrrr/watchtower.git
				synced 2025-10-31 00:17:44 +02:00 
			
		
		
		
	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 <simme@arcticbit.se>
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								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 | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
							
								
								
									
										13
									
								
								pkg/container/container_suite_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								pkg/container/container_suite_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -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") | ||||
| } | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user