mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	distribution: fix errors tests
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
		
							parent
							
								
									7a50fe8a52
								
							
						
					
					
						commit
						588da41f52
					
				
					 1 changed files with 11 additions and 27 deletions
				
			
		| 
						 | 
				
			
			@ -7,26 +7,26 @@ import (
 | 
			
		|||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/docker/distribution/registry/api/errcode"
 | 
			
		||||
	v2 "github.com/docker/distribution/registry/api/v2"
 | 
			
		||||
	"github.com/docker/distribution/registry/client"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var errUnexpected = errors.New("some totally unexpected error")
 | 
			
		||||
 | 
			
		||||
var alwaysContinue = []error{
 | 
			
		||||
	&client.UnexpectedHTTPResponseError{},
 | 
			
		||||
 | 
			
		||||
	// Some errcode.Errors that don't disprove the existence of a V1 image
 | 
			
		||||
	errcode.Error{Code: errcode.ErrorCodeUnauthorized},
 | 
			
		||||
	errcode.Error{Code: v2.ErrorCodeManifestUnknown},
 | 
			
		||||
	errcode.Error{Code: v2.ErrorCodeNameUnknown},
 | 
			
		||||
 | 
			
		||||
	errors.New("some totally unexpected error"),
 | 
			
		||||
	errcode.Errors{},
 | 
			
		||||
	errUnexpected,
 | 
			
		||||
	// nested
 | 
			
		||||
	errcode.Errors{errUnexpected},
 | 
			
		||||
	ErrNoSupport{Err: errUnexpected},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var continueFromMirrorEndpoint = []error{
 | 
			
		||||
	ImageConfigPullError{},
 | 
			
		||||
 | 
			
		||||
	// Some other errcode.Error that doesn't indicate we should search for a V1 image.
 | 
			
		||||
	errcode.Error{Code: errcode.ErrorCodeTooManyRequests},
 | 
			
		||||
	errcode.Error{},
 | 
			
		||||
	// nested
 | 
			
		||||
	errcode.Errors{errcode.Error{}},
 | 
			
		||||
	ErrNoSupport{Err: errcode.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…
	
	Add table
		Add a link
		
	
		Reference in a new issue