-
Notifications
You must be signed in to change notification settings - Fork 883
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make head pull failure warning toggleable (#912)
* feat: make head pull failure warning toggleable * expect prometheus tests to go through EVENTUALLY * wait for queue to be empty before checking test conditions * clean up new head failure toggle * fixup! clean up new head failure toggle * test: add registry tests * test: add warn on head failure tests * fix client interface and make tests hit more lines * make all tests use NewClient instead of creating a struct pointer * fix lint issues Co-authored-by: Simon Aronsson <[email protected]>
- Loading branch information
Showing
13 changed files
with
148 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package registry_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestRegistry(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Registry Suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package registry_test | ||
|
||
import ( | ||
"github.com/containrrr/watchtower/internal/actions/mocks" | ||
unit "github.com/containrrr/watchtower/pkg/registry" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"time" | ||
) | ||
|
||
var _ = Describe("Registry", func() { | ||
Describe("WarnOnAPIConsumption", func() { | ||
When("Given a container with an image from ghcr.io", func() { | ||
It("should want to warn", func() { | ||
Expect(testContainerWithImage("ghcr.io/containrrr/watchtower")).To(BeTrue()) | ||
}) | ||
}) | ||
When("Given a container with an image implicitly from dockerhub", func() { | ||
It("should want to warn", func() { | ||
Expect(testContainerWithImage("docker:latest")).To(BeTrue()) | ||
}) | ||
}) | ||
When("Given a container with an image explicitly from dockerhub", func() { | ||
It("should want to warn", func() { | ||
Expect(testContainerWithImage("registry-1.docker.io/docker:latest")).To(BeTrue()) | ||
Expect(testContainerWithImage("index.docker.io/docker:latest")).To(BeTrue()) | ||
Expect(testContainerWithImage("docker.io/docker:latest")).To(BeTrue()) | ||
}) | ||
|
||
}) | ||
When("Given a container with an image from some other registry", func() { | ||
It("should not want to warn", func() { | ||
Expect(testContainerWithImage("docker.fsf.org/docker:latest")).To(BeFalse()) | ||
Expect(testContainerWithImage("altavista.com/docker:latest")).To(BeFalse()) | ||
Expect(testContainerWithImage("gitlab.com/docker:latest")).To(BeFalse()) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
func testContainerWithImage(imageName string) bool { | ||
container := mocks.CreateMockContainer("", "", imageName, time.Now()) | ||
return unit.WarnOnAPIConsumption(container) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
go test -v -coverprofile coverage.out -covermode atomic ./... | ||
|
||
# Requires CODECOV_TOKEN to be set | ||
bash <(curl -s https://codecov.io/bash) |