forked from TrueCloudLab/distribution
Migrate references to consolidated v2 package
Routes and errors are now all referenced from a single v2 package. This packages exports are acceptable for use in the server side as well as integration into docker core.
This commit is contained in:
parent
5abfc91021
commit
d08f0edcf1
13 changed files with 82 additions and 83 deletions
25
api_test.go
25
api_test.go
|
@ -13,8 +13,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker-registry/api/errors"
|
||||
"github.com/docker/docker-registry/api/urls"
|
||||
"github.com/docker/docker-registry/api/v2"
|
||||
"github.com/docker/docker-registry/common/testutil"
|
||||
"github.com/docker/docker-registry/configuration"
|
||||
"github.com/docker/docker-registry/digest"
|
||||
|
@ -35,7 +34,7 @@ func TestCheckAPI(t *testing.T) {
|
|||
|
||||
app := NewApp(config)
|
||||
server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app))
|
||||
builder, err := urls.NewURLBuilderFromString(server.URL)
|
||||
builder, err := v2.NewURLBuilderFromString(server.URL)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("error creating url builder: %v", err)
|
||||
|
@ -82,7 +81,7 @@ func TestLayerAPI(t *testing.T) {
|
|||
|
||||
app := NewApp(config)
|
||||
server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app))
|
||||
builder, err := urls.NewURLBuilderFromString(server.URL)
|
||||
builder, err := v2.NewURLBuilderFromString(server.URL)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("error creating url builder: %v", err)
|
||||
|
@ -197,7 +196,7 @@ func TestManifestAPI(t *testing.T) {
|
|||
|
||||
app := NewApp(config)
|
||||
server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app))
|
||||
builder, err := urls.NewURLBuilderFromString(server.URL)
|
||||
builder, err := v2.NewURLBuilderFromString(server.URL)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error creating url builder: %v", err)
|
||||
}
|
||||
|
@ -228,7 +227,7 @@ func TestManifestAPI(t *testing.T) {
|
|||
// }
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
|
||||
var respErrs errors.Errors
|
||||
var respErrs v2.Errors
|
||||
if err := dec.Decode(&respErrs); err != nil {
|
||||
t.Fatalf("unexpected error decoding error response: %v", err)
|
||||
}
|
||||
|
@ -237,7 +236,7 @@ func TestManifestAPI(t *testing.T) {
|
|||
t.Fatalf("expected errors in response")
|
||||
}
|
||||
|
||||
if respErrs.Errors[0].Code != errors.ErrorCodeManifestUnknown {
|
||||
if respErrs.Errors[0].Code != v2.ErrorCodeManifestUnknown {
|
||||
t.Fatalf("expected manifest unknown error: got %v", respErrs)
|
||||
}
|
||||
|
||||
|
@ -263,7 +262,7 @@ func TestManifestAPI(t *testing.T) {
|
|||
t.Fatalf("expected errors in response")
|
||||
}
|
||||
|
||||
if respErrs.Errors[0].Code != errors.ErrorCodeNameUnknown {
|
||||
if respErrs.Errors[0].Code != v2.ErrorCodeNameUnknown {
|
||||
t.Fatalf("expected respository unknown error: got %v", respErrs)
|
||||
}
|
||||
|
||||
|
@ -297,11 +296,11 @@ func TestManifestAPI(t *testing.T) {
|
|||
|
||||
for _, err := range respErrs.Errors {
|
||||
switch err.Code {
|
||||
case errors.ErrorCodeManifestUnverified:
|
||||
case v2.ErrorCodeManifestUnverified:
|
||||
unverified++
|
||||
case errors.ErrorCodeBlobUnknown:
|
||||
case v2.ErrorCodeBlobUnknown:
|
||||
missingLayers++
|
||||
case errors.ErrorCodeDigestInvalid:
|
||||
case v2.ErrorCodeDigestInvalid:
|
||||
// TODO(stevvooe): This error isn't quite descriptive enough --
|
||||
// the layer with an invalid digest isn't identified.
|
||||
invalidDigests++
|
||||
|
@ -428,7 +427,7 @@ func putManifest(t *testing.T, msg, url string, v interface{}) *http.Response {
|
|||
return resp
|
||||
}
|
||||
|
||||
func startPushLayer(t *testing.T, ub *urls.URLBuilder, name string) string {
|
||||
func startPushLayer(t *testing.T, ub *v2.URLBuilder, name string) string {
|
||||
layerUploadURL, err := ub.BuildBlobUploadURL(name)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error building layer upload url: %v", err)
|
||||
|
@ -450,7 +449,7 @@ func startPushLayer(t *testing.T, ub *urls.URLBuilder, name string) string {
|
|||
}
|
||||
|
||||
// pushLayer pushes the layer content returning the url on success.
|
||||
func pushLayer(t *testing.T, ub *urls.URLBuilder, name string, dgst digest.Digest, uploadURLBase string, rs io.ReadSeeker) string {
|
||||
func pushLayer(t *testing.T, ub *v2.URLBuilder, name string, dgst digest.Digest, uploadURLBase string, rs io.ReadSeeker) string {
|
||||
rsLength, _ := rs.Seek(0, os.SEEK_END)
|
||||
rs.Seek(0, os.SEEK_SET)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue