Permalink
Browse files

Make the docker-daemon transport stubbable

Make the docker-daemon transport something that can be stubbed out by
supplying the "containers_image_docker_daemon_stub" build tag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
  • Loading branch information...
nalind committed Jul 23, 2018
1 parent c6e0eee commit 1a08fe2e47af58f9e1dca5ecead9722d611dfee4
@@ -9,7 +9,6 @@ import (
_ "github.com/containers/image/directory"
_ "github.com/containers/image/docker"
_ "github.com/containers/image/docker/archive"
_ "github.com/containers/image/docker/daemon"
_ "github.com/containers/image/oci/archive"
_ "github.com/containers/image/oci/layout"
_ "github.com/containers/image/openshift"
@@ -29,8 +29,6 @@ func TestImageNameHandling(t *testing.T) {
{"dir", "/etc", "/etc"},
{"docker", "//busybox", "//busybox:latest"},
{"docker", "//busybox:notlatest", "//busybox:notlatest"}, // This also tests handling of multiple ":" characters
{"docker-daemon", "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"},
{"docker-daemon", "busybox:latest", "busybox:latest"},
{"docker-archive", "/var/lib/oci/busybox.tar:busybox:latest", "/var/lib/oci/busybox.tar:docker.io/library/busybox:latest"},
{"docker-archive", "busybox.tar:busybox:latest", "busybox.tar:docker.io/library/busybox:latest"},
{"oci", "/etc:someimage", "/etc:someimage"},
@@ -48,7 +46,7 @@ func TestImageNameHandling(t *testing.T) {
}
// Possibly stubbed-out transports: Only verify that something is registered.
for _, c := range []string{"ostree"} {
for _, c := range []string{"docker-daemon", "ostree"} {
transport := transports.Get(c)
assert.NotNil(t, transport, c)
}
@@ -0,0 +1,8 @@
// +build !containers_image_docker_daemon_stub
package alltransports
import (
// Register the docker-daemon transport
_ "github.com/containers/image/docker/daemon"
)
@@ -0,0 +1,9 @@
// +build containers_image_docker_daemon_stub
package alltransports
import "github.com/containers/image/transports"
func init() {
transports.Register(transports.NewStubTransport("docker-daemon"))
}

0 comments on commit 1a08fe2

Please sign in to comment.