docker: add test to ensure not found error is returned by resolve
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
b4814a29d4
commit
a1cdf60cb6
@ -31,6 +31,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/remotes"
|
"github.com/containerd/containerd/remotes"
|
||||||
"github.com/containerd/containerd/remotes/docker/auth"
|
"github.com/containerd/containerd/remotes/docker/auth"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
@ -330,6 +331,7 @@ func TestHostTLSFailureFallbackResolver(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runBasicTest(t, "testname", sf)
|
runBasicTest(t, "testname", sf)
|
||||||
|
runNotFoundTest(t, "testname", sf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResolveProxy(t *testing.T) {
|
func TestResolveProxy(t *testing.T) {
|
||||||
@ -607,6 +609,28 @@ func runBasicTest(t *testing.T, name string, sf func(h http.Handler) (string, Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runNotFoundTest(t *testing.T, name string, sf func(h http.Handler) (string, ResolverOptions, func())) {
|
||||||
|
var (
|
||||||
|
ctx = context.Background()
|
||||||
|
tag = "latest"
|
||||||
|
r = http.NewServeMux()
|
||||||
|
)
|
||||||
|
|
||||||
|
base, ro, close := sf(logHandler{t, r})
|
||||||
|
defer close()
|
||||||
|
|
||||||
|
resolver := NewResolver(ro)
|
||||||
|
image := fmt.Sprintf("%s/%s:%s", base, name, tag)
|
||||||
|
|
||||||
|
_, _, err := resolver.Resolve(ctx, image)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("Expected error resolving %s, got nil", image)
|
||||||
|
}
|
||||||
|
if !errors.Is(err, errdefs.ErrNotFound) {
|
||||||
|
t.Fatalf("Expected error resolving %s to be ErrNotFound, got %v", image, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testFetch(ctx context.Context, f remotes.Fetcher, desc ocispec.Descriptor) error {
|
func testFetch(ctx context.Context, f remotes.Fetcher, desc ocispec.Descriptor) error {
|
||||||
r, err := f.Fetch(ctx, desc)
|
r, err := f.Fetch(ctx, desc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user