Open cmoulliard opened 12 months ago
To be investigated
Test is passing locally using as config
func TestReconcileGitServerImage(t *testing.T) {
logf.SetLogger(zap.New(zap.UseDevMode(true)))
ctx := context.Background()
req := testcontainers.ContainerRequest{
Image: "registry:2", // registry image does expose port 5000
WaitingFor: wait.ForListeningPort("5000/tcp"),
ExposedPorts: []string{"5001:5000/tcp"},
}
Proposition
I would like to propose to use this project https://golang.testcontainers.org/quickstart/ for our integration tests when it is needed to launch some containers. Example: To execute this
image_test.go
test, a local registry container is neededWe can easily use testcontainer to bootstrap a container as you can see hereafter:
there is even a trick to bind the needed port (e.g 5001) to the port used by the docker registry:
5000
Test output will be now
NOTE: Test is failing as the imageTag assumes that we pushed the image to the registry
localhost:5001
but as testcontainer generates random port, then test will fail: https://golang.testcontainers.org/features/networking/#exposing-container-ports-to-the-host. To be investigated