distribution: fix errors tests
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
7a50fe8a52
commit
588da41f52
|
@ -7,26 +7,26 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/distribution/registry/api/errcode"
|
"github.com/docker/distribution/registry/api/errcode"
|
||||||
v2 "github.com/docker/distribution/registry/api/v2"
|
|
||||||
"github.com/docker/distribution/registry/client"
|
"github.com/docker/distribution/registry/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var errUnexpected = errors.New("some totally unexpected error")
|
||||||
|
|
||||||
var alwaysContinue = []error{
|
var alwaysContinue = []error{
|
||||||
&client.UnexpectedHTTPResponseError{},
|
&client.UnexpectedHTTPResponseError{},
|
||||||
|
errcode.Errors{},
|
||||||
// Some errcode.Errors that don't disprove the existence of a V1 image
|
errUnexpected,
|
||||||
errcode.Error{Code: errcode.ErrorCodeUnauthorized},
|
// nested
|
||||||
errcode.Error{Code: v2.ErrorCodeManifestUnknown},
|
errcode.Errors{errUnexpected},
|
||||||
errcode.Error{Code: v2.ErrorCodeNameUnknown},
|
ErrNoSupport{Err: errUnexpected},
|
||||||
|
|
||||||
errors.New("some totally unexpected error"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var continueFromMirrorEndpoint = []error{
|
var continueFromMirrorEndpoint = []error{
|
||||||
ImageConfigPullError{},
|
ImageConfigPullError{},
|
||||||
|
errcode.Error{},
|
||||||
// Some other errcode.Error that doesn't indicate we should search for a V1 image.
|
// nested
|
||||||
errcode.Error{Code: errcode.ErrorCodeTooManyRequests},
|
errcode.Errors{errcode.Error{}},
|
||||||
|
ErrNoSupport{Err: errcode.Error{}},
|
||||||
}
|
}
|
||||||
|
|
||||||
var neverContinue = []error{
|
var neverContinue = []error{
|
||||||
|
@ -67,19 +67,3 @@ func TestContinueOnError_NeverContinue(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContinueOnError_UnnestsErrors(t *testing.T) {
|
|
||||||
// ContinueOnError should evaluate nested errcode.Errors.
|
|
||||||
|
|
||||||
// Assumes that v2.ErrorCodeNameUnknown is a continueable error code.
|
|
||||||
err := errcode.Errors{errcode.Error{Code: v2.ErrorCodeNameUnknown}}
|
|
||||||
if !continueOnError(err, false) {
|
|
||||||
t.Fatal("ContinueOnError should unnest, base return value on errcode.Errors")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assumes that errcode.ErrorCodeTooManyRequests is not a V1-fallback indication
|
|
||||||
err = errcode.Errors{errcode.Error{Code: errcode.ErrorCodeTooManyRequests}}
|
|
||||||
if continueOnError(err, false) {
|
|
||||||
t.Fatal("ContinueOnError should unnest, base return value on errcode.Errors")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue