Fix silly testing format mistakes

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
Milos Gajdos 2024-08-30 11:18:18 +01:00
parent 170ac07a5e
commit a940e61623
No known key found for this signature in database
31 changed files with 132 additions and 132 deletions

View File

@ -336,7 +336,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) {
} }
if creds.refreshTokens[service] != refreshToken2 { if creds.refreshTokens[service] != refreshToken2 {
t.Fatalf("Refresh token not set after change") t.Fatal("Refresh token not set after change")
} }
// Try with bad token // Try with bad token

View File

@ -146,14 +146,14 @@ func TestUploadReadFrom(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.ReadFrom(bytes.NewReader(b)) _, err = blobUpload.ReadFrom(bytes.NewReader(b))
if err == nil { if err == nil {
t.Fatalf("Expected error when bad range received") t.Fatal("Expected error when bad range received")
} }
// 404 // 404
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.ReadFrom(bytes.NewReader(b)) _, err = blobUpload.ReadFrom(bytes.NewReader(b))
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if err != distribution.ErrBlobUploadUnknown { if err != distribution.ErrBlobUploadUnknown {
t.Fatalf("Wrong error thrown: %s, expected %s", err, distribution.ErrBlobUploadUnknown) t.Fatalf("Wrong error thrown: %s, expected %s", err, distribution.ErrBlobUploadUnknown)
@ -163,7 +163,7 @@ func TestUploadReadFrom(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.ReadFrom(bytes.NewReader(b)) _, err = blobUpload.ReadFrom(bytes.NewReader(b))
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if uploadErr, ok := err.(errcode.Errors); !ok { if uploadErr, ok := err.(errcode.Errors); !ok {
t.Fatalf("Wrong error type %T: %s", err, err) t.Fatalf("Wrong error type %T: %s", err, err)
@ -189,7 +189,7 @@ func TestUploadReadFrom(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.ReadFrom(bytes.NewReader(b)) _, err = blobUpload.ReadFrom(bytes.NewReader(b))
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if uploadErr, ok := err.(*UnexpectedHTTPResponseError); !ok { if uploadErr, ok := err.(*UnexpectedHTTPResponseError); !ok {
t.Fatalf("Wrong error type %T: %s", err, err) t.Fatalf("Wrong error type %T: %s", err, err)
@ -204,7 +204,7 @@ func TestUploadReadFrom(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.ReadFrom(bytes.NewReader(b)) _, err = blobUpload.ReadFrom(bytes.NewReader(b))
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if uploadErr, ok := err.(*UnexpectedHTTPStatusError); !ok { if uploadErr, ok := err.(*UnexpectedHTTPStatusError); !ok {
t.Fatalf("Wrong error type %T: %s", err, err) t.Fatalf("Wrong error type %T: %s", err, err)
@ -434,14 +434,14 @@ func TestUploadWrite(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.Write(b) _, err = blobUpload.Write(b)
if err == nil { if err == nil {
t.Fatalf("Expected error when bad range received") t.Fatal("Expected error when bad range received")
} }
// 404 // 404
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.Write(b) _, err = blobUpload.Write(b)
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if err != distribution.ErrBlobUploadUnknown { if err != distribution.ErrBlobUploadUnknown {
t.Fatalf("Wrong error thrown: %s, expected %s", err, distribution.ErrBlobUploadUnknown) t.Fatalf("Wrong error thrown: %s, expected %s", err, distribution.ErrBlobUploadUnknown)
@ -451,7 +451,7 @@ func TestUploadWrite(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.Write(b) _, err = blobUpload.Write(b)
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if uploadErr, ok := err.(errcode.Errors); !ok { if uploadErr, ok := err.(errcode.Errors); !ok {
t.Fatalf("Wrong error type %T: %s", err, err) t.Fatalf("Wrong error type %T: %s", err, err)
@ -477,7 +477,7 @@ func TestUploadWrite(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.Write(b) _, err = blobUpload.Write(b)
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if uploadErr, ok := err.(*UnexpectedHTTPResponseError); !ok { if uploadErr, ok := err.(*UnexpectedHTTPResponseError); !ok {
t.Fatalf("Wrong error type %T: %s", err, err) t.Fatalf("Wrong error type %T: %s", err, err)
@ -492,7 +492,7 @@ func TestUploadWrite(t *testing.T) {
blobUpload.location = e + locationPath blobUpload.location = e + locationPath
_, err = blobUpload.Write(b) _, err = blobUpload.Write(b)
if err == nil { if err == nil {
t.Fatalf("Expected error when not found") t.Fatal("Expected error when not found")
} }
if uploadErr, ok := err.(*UnexpectedHTTPStatusError); !ok { if uploadErr, ok := err.(*UnexpectedHTTPStatusError); !ok {
t.Fatalf("Wrong error type %T: %s", err, err) t.Fatalf("Wrong error type %T: %s", err, err)

View File

@ -394,7 +394,7 @@ func TestBlobExistsNoContentLength(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !strings.Contains(err.Error(), "missing content-length heade") { if !strings.Contains(err.Error(), "missing content-length heade") {
t.Fatalf("Expected missing content-length error message") t.Fatal("Expected missing content-length error message")
} }
} }
@ -1468,10 +1468,10 @@ func TestObtainsErrorForMissingTag(t *testing.T) {
_, err = tagService.Get(ctx, "1.0.0") _, err = tagService.Get(ctx, "1.0.0")
if err == nil { if err == nil {
t.Fatalf("Expected an error") t.Fatal("Expected an error")
} }
if !strings.Contains(err.Error(), "manifest unknown") { if !strings.Contains(err.Error(), "manifest unknown") {
t.Fatalf("Expected unknown manifest error message") t.Fatal("Expected unknown manifest error message")
} }
} }
@ -1495,10 +1495,10 @@ func TestObtainsManifestForTagWithoutHeaders(t *testing.T) {
desc, err := tagService.Get(ctx, "1.0.0") desc, err := tagService.Get(ctx, "1.0.0")
if err != nil { if err != nil {
t.Fatalf("Expected no error") t.Fatal("Expected no error")
} }
if desc.Digest != dgst { if desc.Digest != dgst {
t.Fatalf("Unexpected digest") t.Fatal("Unexpected digest")
} }
} }
@ -1657,7 +1657,7 @@ func TestCatalog(t *testing.T) {
} }
if numFilled != 3 { if numFilled != 3 {
t.Fatalf("Got wrong number of repos") t.Fatal("Got wrong number of repos")
} }
} }
@ -1689,7 +1689,7 @@ func TestCatalogInParts(t *testing.T) {
} }
if numFilled != 2 { if numFilled != 2 {
t.Fatalf("Got wrong number of repos") t.Fatal("Got wrong number of repos")
} }
numFilled, err = r.Repositories(ctx, entries, "baz") numFilled, err = r.Repositories(ctx, entries, "baz")
@ -1698,7 +1698,7 @@ func TestCatalogInParts(t *testing.T) {
} }
if numFilled != 1 { if numFilled != 1 {
t.Fatalf("Got wrong number of repos") t.Fatal("Got wrong number of repos")
} }
} }

View File

@ -164,7 +164,7 @@ func TestWithResponseWriter(t *testing.T) {
rw.(http.Flusher).Flush() rw.(http.Flusher).Flush()
if !trw.flushed { if !trw.flushed {
t.Fatalf("response writer not flushed") t.Fatal("response writer not flushed")
} }
// Write another status and make sure context is correct. This normally // Write another status and make sure context is correct. This normally

View File

@ -6,7 +6,7 @@ func TestVersionContext(t *testing.T) {
ctx := Background() ctx := Background()
if GetVersion(ctx) != "" { if GetVersion(ctx) != "" {
t.Fatalf("context should not yet have a version") t.Fatal("context should not yet have a version")
} }
expected := "2.1-whatever" expected := "2.1-whatever"

View File

@ -146,7 +146,7 @@ func mediaTypeTest(contentType string, mediaType string, shouldError bool) func(
if shouldError { if shouldError {
if err == nil { if err == nil {
t.Fatalf("bad content type should have produced error") t.Fatal("bad content type should have produced error")
} }
} else { } else {
if err != nil { if err != nil {

View File

@ -146,7 +146,7 @@ func TestOCIManifestIndexUnmarshal(t *testing.T) {
t.Fatalf("manifest index annotation not equal:\nexpected:\n%v\nactual:\n%v\n", deserialized.Annotations, descriptor.Annotations) t.Fatalf("manifest index annotation not equal:\nexpected:\n%v\nactual:\n%v\n", deserialized.Annotations, descriptor.Annotations)
} }
if len(descriptor.Annotations) != 2 { if len(descriptor.Annotations) != 2 {
t.Fatalf("manifest index annotation length should be 2") t.Fatal("manifest index annotation length should be 2")
} }
if descriptor.Size != int64(len([]byte(expectedOCIImageIndexSerialization))) { if descriptor.Size != int64(len([]byte(expectedOCIImageIndexSerialization))) {
t.Fatalf("manifest index size is not correct:\nexpected:\n%d\nactual:\n%v\n", int64(len([]byte(expectedOCIImageIndexSerialization))), descriptor.Size) t.Fatalf("manifest index size is not correct:\nexpected:\n%d\nactual:\n%v\n", int64(len([]byte(expectedOCIImageIndexSerialization))), descriptor.Size)
@ -175,7 +175,7 @@ func indexMediaTypeTest(contentType string, mediaType string, shouldError bool)
if shouldError { if shouldError {
if err == nil { if err == nil {
t.Fatalf("bad content type should have produced error") t.Fatal("bad content type should have produced error")
} }
} else { } else {
if err != nil { if err != nil {

View File

@ -157,7 +157,7 @@ func TestManifestUnmarshal(t *testing.T) {
t.Fatalf("manifest annotation not equal:\nexpected:\n%v\nactual:\n%v\n", deserialized.Annotations, descriptor.Annotations) t.Fatalf("manifest annotation not equal:\nexpected:\n%v\nactual:\n%v\n", deserialized.Annotations, descriptor.Annotations)
} }
if len(descriptor.Annotations) != 1 { if len(descriptor.Annotations) != 1 {
t.Fatalf("manifest index annotation length should be 1") t.Fatal("manifest index annotation length should be 1")
} }
if descriptor.Size != int64(len([]byte(expectedManifestSerialization))) { if descriptor.Size != int64(len([]byte(expectedManifestSerialization))) {
t.Fatalf("manifest size is not correct:\nexpected:\n%d\nactual:\n%v\n", int64(len([]byte(expectedManifestSerialization))), descriptor.Size) t.Fatalf("manifest size is not correct:\nexpected:\n%d\nactual:\n%v\n", int64(len([]byte(expectedManifestSerialization))), descriptor.Size)
@ -185,7 +185,7 @@ func manifestMediaTypeTest(mediaType string, shouldError bool) func(*testing.T)
if shouldError { if shouldError {
if err == nil { if err == nil {
t.Fatalf("bad content type should have produced error") t.Fatal("bad content type should have produced error")
} }
} else { } else {
if err != nil { if err != nil {

View File

@ -130,7 +130,7 @@ func mediaTypeTest(t *testing.T, mediaType string, shouldError bool) {
if shouldError { if shouldError {
if err == nil { if err == nil {
t.Fatalf("bad content type should have produced error") t.Fatal("bad content type should have produced error")
} }
} else { } else {
if err != nil { if err != nil {

View File

@ -179,7 +179,7 @@ func TestHTTPSink(t *testing.T) {
} }
} else { } else {
if err == nil { if err == nil {
t.Fatalf("the endpoint should have rejected the request") t.Fatal("the endpoint should have rejected the request")
} }
t.Logf("write error: %v", err) t.Logf("write error: %v", err)
} }

View File

@ -178,12 +178,12 @@ func checkTestRepository(t *testing.T, repository distribution.Repository, remov
sm, err := schema2.FromStruct(m) sm, err := schema2.FromStruct(m)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
manifests, err := repository.Manifests(ctx) manifests, err := repository.Manifests(ctx)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
var digestPut digest.Digest var digestPut digest.Digest
@ -193,12 +193,12 @@ func checkTestRepository(t *testing.T, repository distribution.Repository, remov
_, canonical, err := sm.Payload() _, canonical, err := sm.Payload()
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
dgst := digest.FromBytes(canonical) dgst := digest.FromBytes(canonical)
if dgst != digestPut { if dgst != digestPut {
t.Fatalf("mismatching digest from payload and put") t.Fatal("mismatching digest from payload and put")
} }
if err := repository.Tags(ctx).Tag(ctx, tag, distribution.Descriptor{Digest: dgst}); err != nil { if err := repository.Tags(ctx).Tag(ctx, tag, distribution.Descriptor{Digest: dgst}); err != nil {

View File

@ -51,7 +51,7 @@ func TestEventQueue(t *testing.T) {
} }
if !ts.closed { if !ts.closed {
t.Fatalf("sink should have been closed") t.Fatal("sink should have been closed")
} }
if metrics.Events != nevents { if metrics.Events != nevents {
@ -162,13 +162,13 @@ func checkClose(t *testing.T, sink events.Sink) {
// second close should not crash but should return an error. // second close should not crash but should return an error.
if err := sink.Close(); err == nil { if err := sink.Close(); err == nil {
t.Fatalf("no error on double close") t.Fatal("no error on double close")
} }
// Write after closed should be an error // Write after closed should be an error
if err := sink.Write(Event{}); err == nil { if err := sink.Write(Event{}); err == nil {
t.Fatalf("write after closed did not have an error") t.Fatal("write after closed did not have an error")
} else if err != ErrSinkClosed { } else if err != ErrSinkClosed {
t.Fatalf("error should be ErrSinkClosed") t.Fatal("error should be ErrSinkClosed")
} }
} }

View File

@ -169,7 +169,7 @@ func TestErrorsManagement(t *testing.T) {
e1 = ErrorCodeTest3.WithArgs("test1") e1 = ErrorCodeTest3.WithArgs("test1")
e2 := e1.WithArgs("test2") e2 := e1.WithArgs("test2")
if &e1 == &e2 { if &e1 == &e2 {
t.Fatalf("args: e2 and e1 should not be the same, but they are") t.Fatal("args: e2 and e1 should not be the same, but they are")
} }
if e2.Message != `Sorry "test2" isn't valid` { if e2.Message != `Sorry "test2" isn't valid` {
t.Fatalf("e2 had wrong message: %q", e2.Message) t.Fatalf("e2 had wrong message: %q", e2.Message)
@ -180,7 +180,7 @@ func TestErrorsManagement(t *testing.T) {
e1 = ErrorCodeTest3.WithDetail("stuff1") e1 = ErrorCodeTest3.WithDetail("stuff1")
e2 = e1.WithDetail("stuff2") e2 = e1.WithDetail("stuff2")
if &e1 == &e2 { if &e1 == &e2 {
t.Fatalf("detail: e2 and e1 should not be the same, but they are") t.Fatal("detail: e2 and e1 should not be the same, but they are")
} }
if e2.Detail != `stuff2` { if e2.Detail != `stuff2` {
t.Fatalf("e2 had wrong detail: %q", e2.Detail) t.Fatalf("e2 had wrong detail: %q", e2.Detail)

View File

@ -119,7 +119,7 @@ func TestCatalogAPI(t *testing.T) {
// No pagination should be returned // No pagination should be returned
if resp.Header.Get("Link") != "" { if resp.Header.Get("Link") != "" {
t.Fatalf("repositories has more data when none expected") t.Fatal("repositories has more data when none expected")
} }
for _, image := range allCatalog { for _, image := range allCatalog {
@ -157,7 +157,7 @@ func TestCatalogAPI(t *testing.T) {
// fail if there's no pagination // fail if there's no pagination
link := resp.Header.Get("Link") link := resp.Header.Get("Link")
if link == "" { if link == "" {
t.Fatalf("repositories has less data than expected") t.Fatal("repositories has less data than expected")
} }
// ----------------------------------- // -----------------------------------
// Case No. 2.1: Second page (n internally will be min(100, maxEntries)) // Case No. 2.1: Second page (n internally will be min(100, maxEntries))
@ -221,7 +221,7 @@ func TestCatalogAPI(t *testing.T) {
// fail if there's no pagination // fail if there's no pagination
link = resp.Header.Get("Link") link = resp.Header.Get("Link")
if link == "" { if link == "" {
t.Fatalf("repositories has less data than expected") t.Fatal("repositories has less data than expected")
} }
// ----------------------------------- // -----------------------------------
@ -287,7 +287,7 @@ func TestCatalogAPI(t *testing.T) {
// fail if there's no pagination // fail if there's no pagination
link = resp.Header.Get("Link") link = resp.Header.Get("Link")
if link == "" { if link == "" {
t.Fatalf("repositories has less data than expected") t.Fatal("repositories has less data than expected")
} }
// ----------------------------------- // -----------------------------------
@ -612,7 +612,7 @@ func checkLink(t *testing.T, urlStr string, numEntries int, last string) url.Val
matches := re.FindStringSubmatch(urlStr) matches := re.FindStringSubmatch(urlStr)
if len(matches) != 2 { if len(matches) != 2 {
t.Fatalf("Catalog link address response was incorrect") t.Fatal("Catalog link address response was incorrect")
} }
linkURL, _ := url.Parse(matches[1]) linkURL, _ := url.Parse(matches[1])
urlValues := linkURL.Query() urlValues := linkURL.Query()
@ -1037,7 +1037,7 @@ func testBlobAPI(t *testing.T, env *testEnv, args blobArgs) *testEnv {
} }
if !verifier.Verified() { if !verifier.Verified() {
t.Fatalf("response body did not pass verification") t.Fatal("response body did not pass verification")
} }
// ---------------- // ----------------
@ -1107,7 +1107,7 @@ func testBlobDelete(t *testing.T, env *testEnv, args blobArgs) {
ref, _ := reference.WithDigest(imageName, layerDigest) ref, _ := reference.WithDigest(imageName, layerDigest)
layerURL, err := env.builder.BuildBlobURL(ref) layerURL, err := env.builder.BuildBlobURL(ref)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
// --------------- // ---------------
// Delete a layer // Delete a layer
@ -1201,7 +1201,7 @@ func TestDeleteDisabled(t *testing.T) {
ref, _ := reference.WithDigest(imageName, layerDigest) ref, _ := reference.WithDigest(imageName, layerDigest)
layerURL, err := env.builder.BuildBlobURL(ref) layerURL, err := env.builder.BuildBlobURL(ref)
if err != nil { if err != nil {
t.Fatalf("Error building blob URL") t.Fatal("Error building blob URL")
} }
uploadURLBase, _ := startPushLayer(t, env, imageName) uploadURLBase, _ := startPushLayer(t, env, imageName)
pushLayer(t, env.builder, imageName, layerDigest, uploadURLBase, layerFile) pushLayer(t, env.builder, imageName, layerDigest, uploadURLBase, layerFile)
@ -1229,7 +1229,7 @@ func TestDeleteReadOnly(t *testing.T) {
ref, _ := reference.WithDigest(imageName, layerDigest) ref, _ := reference.WithDigest(imageName, layerDigest)
layerURL, err := env.builder.BuildBlobURL(ref) layerURL, err := env.builder.BuildBlobURL(ref)
if err != nil { if err != nil {
t.Fatalf("Error building blob URL") t.Fatal("Error building blob URL")
} }
uploadURLBase, _ := startPushLayer(t, env, imageName) uploadURLBase, _ := startPushLayer(t, env, imageName)
pushLayer(t, env.builder, imageName, layerDigest, uploadURLBase, layerFile) pushLayer(t, env.builder, imageName, layerDigest, uploadURLBase, layerFile)
@ -1764,7 +1764,7 @@ func testManifestAPISchema2(t *testing.T, env *testEnv, imageName reference.Name
} }
if !bytes.Equal(fetchedCanonical, canonical) { if !bytes.Equal(fetchedCanonical, canonical) {
t.Fatalf("manifests do not match") t.Fatal("manifests do not match")
} }
// --------------- // ---------------
@ -1822,7 +1822,7 @@ func testManifestAPISchema2(t *testing.T, env *testEnv, imageName reference.Name
} }
if !bytes.Equal(fetchedCanonical, canonical) { if !bytes.Equal(fetchedCanonical, canonical) {
t.Fatalf("manifests do not match") t.Fatal("manifests do not match")
} }
// Get by name with etag, gives 304 // Get by name with etag, gives 304
@ -1997,7 +1997,7 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs)
} }
if !bytes.Equal(fetchedCanonical, canonical) { if !bytes.Equal(fetchedCanonical, canonical) {
t.Fatalf("manifest lists do not match") t.Fatal("manifest lists do not match")
} }
// --------------- // ---------------
@ -2029,7 +2029,7 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs)
} }
if !bytes.Equal(fetchedCanonical, canonical) { if !bytes.Equal(fetchedCanonical, canonical) {
t.Fatalf("manifests do not match") t.Fatal("manifests do not match")
} }
// Get by name with etag, gives 304 // Get by name with etag, gives 304
@ -2389,7 +2389,7 @@ func pushLayer(t *testing.T, ub *v2.URLBuilder, name reference.Named, dgst diges
checkResponse(t, "putting monolithic chunk", resp, http.StatusCreated) checkResponse(t, "putting monolithic chunk", resp, http.StatusCreated)
if err != nil { if err != nil {
t.Fatalf("error generating sha256 digest of body") t.Fatal("error generating sha256 digest of body")
} }
sha256Dgst := digester.Digest() sha256Dgst := digester.Digest()
@ -2497,7 +2497,7 @@ func pushChunk(t *testing.T, ub *v2.URLBuilder, name reference.Named, uploadURLB
checkResponse(t, "putting chunk", resp, http.StatusAccepted) checkResponse(t, "putting chunk", resp, http.StatusAccepted)
if err != nil { if err != nil {
t.Fatalf("error generating sha256 digest of body") t.Fatal("error generating sha256 digest of body")
} }
checkHeaders(t, resp, http.Header{ checkHeaders(t, resp, http.Header{
@ -2540,7 +2540,7 @@ func checkBodyHasErrorCodes(t *testing.T, msg string, resp *http.Response, error
} }
if len(errs) == 0 { if len(errs) == 0 {
t.Fatalf("expected errors in response") t.Fatal("expected errors in response")
} }
// TODO(stevvooe): Shoot. The error setup is not working out. The content- // TODO(stevvooe): Shoot. The error setup is not working out. The content-
@ -2843,7 +2843,7 @@ func TestProxyManifestGetByTag(t *testing.T) {
// Create another manifest in the remote with the same image/tag pair // Create another manifest in the remote with the same image/tag pair
newDigest := createRepository(truthEnv, t, imageName.Name(), tag) newDigest := createRepository(truthEnv, t, imageName.Name(), tag)
if dgst == newDigest { if dgst == newDigest {
t.Fatalf("non-random test data") t.Fatal("non-random test data")
} }
// fetch it with the same proxy URL as before. Ensure the updated content is at the same tag // fetch it with the same proxy URL as before. Ensure the updated content is at the same tag

View File

@ -237,41 +237,41 @@ func TestAppendAccessRecords(t *testing.T) {
result := appendAccessRecords(records, http.MethodGet, repo) result := appendAccessRecords(records, http.MethodGet, repo)
expectedResult := []auth.Access{expectedPullRecord} expectedResult := []auth.Access{expectedPullRecord}
if ok := reflect.DeepEqual(result, expectedResult); !ok { if ok := reflect.DeepEqual(result, expectedResult); !ok {
t.Fatalf("Actual access record differs from expected") t.Fatal("Actual access record differs from expected")
} }
records = []auth.Access{} records = []auth.Access{}
result = appendAccessRecords(records, http.MethodHead, repo) result = appendAccessRecords(records, http.MethodHead, repo)
expectedResult = []auth.Access{expectedPullRecord} expectedResult = []auth.Access{expectedPullRecord}
if ok := reflect.DeepEqual(result, expectedResult); !ok { if ok := reflect.DeepEqual(result, expectedResult); !ok {
t.Fatalf("Actual access record differs from expected") t.Fatal("Actual access record differs from expected")
} }
records = []auth.Access{} records = []auth.Access{}
result = appendAccessRecords(records, http.MethodPost, repo) result = appendAccessRecords(records, http.MethodPost, repo)
expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord}
if ok := reflect.DeepEqual(result, expectedResult); !ok { if ok := reflect.DeepEqual(result, expectedResult); !ok {
t.Fatalf("Actual access record differs from expected") t.Fatal("Actual access record differs from expected")
} }
records = []auth.Access{} records = []auth.Access{}
result = appendAccessRecords(records, http.MethodPut, repo) result = appendAccessRecords(records, http.MethodPut, repo)
expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord}
if ok := reflect.DeepEqual(result, expectedResult); !ok { if ok := reflect.DeepEqual(result, expectedResult); !ok {
t.Fatalf("Actual access record differs from expected") t.Fatal("Actual access record differs from expected")
} }
records = []auth.Access{} records = []auth.Access{}
result = appendAccessRecords(records, http.MethodPatch, repo) result = appendAccessRecords(records, http.MethodPatch, repo)
expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord}
if ok := reflect.DeepEqual(result, expectedResult); !ok { if ok := reflect.DeepEqual(result, expectedResult); !ok {
t.Fatalf("Actual access record differs from expected") t.Fatal("Actual access record differs from expected")
} }
records = []auth.Access{} records = []auth.Access{}
result = appendAccessRecords(records, http.MethodDelete, repo) result = appendAccessRecords(records, http.MethodDelete, repo)
expectedResult = []auth.Access{expectedDeleteRecord} expectedResult = []auth.Access{expectedDeleteRecord}
if ok := reflect.DeepEqual(result, expectedResult); !ok { if ok := reflect.DeepEqual(result, expectedResult); !ok {
t.Fatalf("Actual access record differs from expected") t.Fatal("Actual access record differs from expected")
} }
} }

View File

@ -209,7 +209,7 @@ func populate(t *testing.T, te *testEnv, blobCount, size, numUnique int) {
for j := 0; j < blobCount/numUnique; j++ { for j := 0; j < blobCount/numUnique; j++ {
desc, err := te.store.remoteStore.Put(te.ctx, "", bytes) desc, err := te.store.remoteStore.Put(te.ctx, "", bytes)
if err != nil { if err != nil {
t.Fatalf("Put in store") t.Fatal("Put in store")
} }
inRemote = append(inRemote, desc) inRemote = append(inRemote, desc)
@ -279,7 +279,7 @@ func TestProxyStoreStat(t *testing.T) {
for _, d := range te.inRemote { for _, d := range te.inRemote {
_, err := te.store.Stat(te.ctx, d.Digest) _, err := te.store.Stat(te.ctx, d.Digest)
if err != nil { if err != nil {
t.Fatalf("Error stating proxy store") t.Fatal("Error stating proxy store")
} }
} }
@ -444,7 +444,7 @@ func testProxyStoreServe(t *testing.T, te *testEnv, numClients int) {
err = te.store.ServeBlob(te.ctx, w, r, remoteBlob.Digest) err = te.store.ServeBlob(te.ctx, w, r, remoteBlob.Digest)
if err != nil { if err != nil {
t.Error(err.Error()) t.Error(err)
return return
} }
@ -452,7 +452,7 @@ func testProxyStoreServe(t *testing.T, te *testEnv, numClients int) {
bodyBytes, err := io.ReadAll(resp.Body) bodyBytes, err := io.ReadAll(resp.Body)
resp.Body.Close() resp.Body.Close()
if err != nil { if err != nil {
t.Error(err.Error()) t.Error(err)
return return
} }
localDigest := digest.FromBytes(bodyBytes) localDigest := digest.FromBytes(bodyBytes)
@ -513,7 +513,7 @@ func testProxyStoreServe(t *testing.T, te *testEnv, numClients int) {
err = te.store.ServeBlob(te.ctx, w, r, dr.Digest) err = te.store.ServeBlob(te.ctx, w, r, dr.Digest)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
dl := digest.FromBytes(w.Body.Bytes()) dl := digest.FromBytes(w.Body.Bytes())

View File

@ -99,7 +99,7 @@ func newManifestStoreTestEnv(t *testing.T, name, tag string) *manifestStoreTestE
} }
tr, err := truthRepo.Manifests(ctx) tr, err := truthRepo.Manifests(ctx)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
truthManifests := statsManifest{ truthManifests := statsManifest{
manifests: tr, manifests: tr,
@ -108,7 +108,7 @@ func newManifestStoreTestEnv(t *testing.T, name, tag string) *manifestStoreTestE
manifestDigest, err := populateRepo(ctx, t, truthRepo, name, tag) manifestDigest, err := populateRepo(ctx, t, truthRepo, name, tag)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
localRegistry, err := storage.NewRegistry(ctx, inmemory.New(), localRegistry, err := storage.NewRegistry(ctx, inmemory.New(),
@ -122,7 +122,7 @@ func newManifestStoreTestEnv(t *testing.T, name, tag string) *manifestStoreTestE
} }
lr, err := localRepo.Manifests(ctx, storage.SkipLayerVerification()) lr, err := localRepo.Manifests(ctx, storage.SkipLayerVerification())
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
localManifests := statsManifest{ localManifests := statsManifest{
@ -165,7 +165,7 @@ func populateRepo(ctx context.Context, t *testing.T, repository distribution.Rep
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
rs, dgst, err := testutil.CreateRandomTarFile() rs, dgst, err := testutil.CreateRandomTarFile()
if err != nil { if err != nil {
t.Fatalf("unexpected error generating test layer file") t.Fatal("unexpected error generating test layer file")
} }
if err := testutil.PushBlob(ctx, repository, rs, dgst); err != nil { if err := testutil.PushBlob(ctx, repository, rs, dgst); err != nil {
@ -175,11 +175,11 @@ func populateRepo(ctx context.Context, t *testing.T, repository distribution.Rep
ms, err := repository.Manifests(ctx) ms, err := repository.Manifests(ctx)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
sm, err := schema2.FromStruct(m) sm, err := schema2.FromStruct(m)
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
dgst, err := ms.Put(ctx, sm) dgst, err := ms.Put(ctx, sm)
if err != nil { if err != nil {
@ -202,7 +202,7 @@ func TestProxyManifests(t *testing.T) {
// Stat - must check local and remote // Stat - must check local and remote
exists, err := env.manifests.Exists(ctx, env.manifestDigest) exists, err := env.manifests.Exists(ctx, env.manifestDigest)
if err != nil { if err != nil {
t.Fatalf("Error checking existence") t.Fatal("Error checking existence")
} }
if !exists { if !exists {
t.Errorf("Unexpected non-existent manifest") t.Errorf("Unexpected non-existent manifest")
@ -270,7 +270,7 @@ func TestProxyManifestsWithoutScheduler(t *testing.T) {
ctx := context.Background() ctx := context.Background()
exists, err := env.manifests.Exists(ctx, env.manifestDigest) exists, err := env.manifests.Exists(ctx, env.manifestDigest)
if err != nil { if err != nil {
t.Fatalf("Error checking existence") t.Fatal("Error checking existence")
} }
if !exists { if !exists {
t.Errorf("Unexpected non-existent manifest") t.Errorf("Unexpected non-existent manifest")

View File

@ -98,7 +98,7 @@ func TestGet(t *testing.T) {
} }
if !reflect.DeepEqual(local, remoteDesc) { if !reflect.DeepEqual(local, remoteDesc) {
t.Fatalf("unexpected descriptor pulled through") t.Fatal("unexpected descriptor pulled through")
} }
// Manually overwrite remote tag // Manually overwrite remote tag
@ -134,12 +134,12 @@ func TestGet(t *testing.T) {
_, err = proxyTags.localTags.Get(ctx, remoteTag) _, err = proxyTags.localTags.Get(ctx, remoteTag)
if err == nil { if err == nil {
t.Fatalf("Expected error getting Untag'd tag") t.Fatal("Expected error getting Untag'd tag")
} }
_, err = proxyTags.remoteTags.Get(ctx, remoteTag) _, err = proxyTags.remoteTags.Get(ctx, remoteTag)
if err != nil { if err != nil {
t.Fatalf("remote tag should not be untagged with proxyTag.Untag") t.Fatal("remote tag should not be untagged with proxyTag.Untag")
} }
_, err = proxyTags.Get(ctx, remoteTag) _, err = proxyTags.Get(ctx, remoteTag)

View File

@ -43,7 +43,7 @@ func TestSchedule(t *testing.T) {
s := New(dcontext.Background(), inmemory.New(), "/ttl") s := New(dcontext.Background(), inmemory.New(), "/ttl")
deleteFunc := func(repoName reference.Reference) error { deleteFunc := func(repoName reference.Reference) error {
if len(remainingRepos) == 0 { if len(remainingRepos) == 0 {
t.Fatalf("Incorrect expiry count") t.Fatal("Incorrect expiry count")
} }
_, ok := remainingRepos[repoName.String()] _, ok := remainingRepos[repoName.String()]
if !ok { if !ok {
@ -175,7 +175,7 @@ func TestStopRestore(t *testing.T) {
err := s.Start() err := s.Start()
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
s.add(ref1, 300*timeUnit, entryTypeBlob) s.add(ref1, 300*timeUnit, entryTypeBlob)
s.add(ref2, 100*timeUnit, entryTypeBlob) s.add(ref2, 100*timeUnit, entryTypeBlob)
@ -184,7 +184,7 @@ func TestStopRestore(t *testing.T) {
// state will be written to fs // state will be written to fs
err = s.Stop() err = s.Stop()
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
time.Sleep(10 * time.Millisecond) time.Sleep(10 * time.Millisecond)
@ -208,10 +208,10 @@ func TestDoubleStart(t *testing.T) {
s := New(dcontext.Background(), inmemory.New(), "/ttl") s := New(dcontext.Background(), inmemory.New(), "/ttl")
err := s.Start() err := s.Start()
if err != nil { if err != nil {
t.Fatalf("Unable to start scheduler") t.Fatal("Unable to start scheduler")
} }
err = s.Start() err = s.Start()
if err == nil { if err == nil {
t.Fatalf("Scheduler started twice without error") t.Fatal("Scheduler started twice without error")
} }
} }

View File

@ -116,7 +116,7 @@ func TestSimpleBlobUpload(t *testing.T) {
} }
if nn != randomDataSize { if nn != randomDataSize {
t.Fatalf("layer data write incomplete") t.Fatal("layer data write incomplete")
} }
blobUpload.Close() blobUpload.Close()
@ -173,7 +173,7 @@ func TestSimpleBlobUpload(t *testing.T) {
} }
if nn != randomDataSize { if nn != randomDataSize {
t.Fatalf("incorrect read length") t.Fatal("incorrect read length")
} }
if digest.NewDigest("sha256", h) != sha256Digest { if digest.NewDigest("sha256", h) != sha256Digest {
@ -183,7 +183,7 @@ func TestSimpleBlobUpload(t *testing.T) {
// Delete a blob // Delete a blob
err = bs.Delete(ctx, desc.Digest) err = bs.Delete(ctx, desc.Digest)
if err != nil { if err != nil {
t.Fatalf("Unexpected error deleting blob") t.Fatal("Unexpected error deleting blob")
} }
d, err := bs.Stat(ctx, desc.Digest) d, err := bs.Stat(ctx, desc.Digest)
@ -200,7 +200,7 @@ func TestSimpleBlobUpload(t *testing.T) {
_, err = bs.Open(ctx, desc.Digest) _, err = bs.Open(ctx, desc.Digest)
if err == nil { if err == nil {
t.Fatalf("unexpected success opening deleted blob for read") t.Fatal("unexpected success opening deleted blob for read")
} }
switch err { switch err {
@ -350,7 +350,7 @@ func TestSimpleBlobRead(t *testing.T) {
} }
if !bytes.Equal(p, randomLayerData) { if !bytes.Equal(p, randomLayerData) {
t.Fatalf("layer data not equal") t.Fatal("layer data not equal")
} }
} }
@ -462,7 +462,7 @@ func TestBlobMount(t *testing.T) {
} }
if nn != randomDataSize { if nn != randomDataSize {
t.Fatalf("incorrect read length") t.Fatal("incorrect read length")
} }
if digest.NewDigest("sha256", h) != dgst { if digest.NewDigest("sha256", h) != dgst {
@ -472,7 +472,7 @@ func TestBlobMount(t *testing.T) {
// Delete the blob from the source repo // Delete the blob from the source repo
err = sbs.Delete(ctx, desc.Digest) err = sbs.Delete(ctx, desc.Digest)
if err != nil { if err != nil {
t.Fatalf("Unexpected error deleting blob") t.Fatal("Unexpected error deleting blob")
} }
_, err = bs.Stat(ctx, desc.Digest) _, err = bs.Stat(ctx, desc.Digest)
@ -495,7 +495,7 @@ func TestBlobMount(t *testing.T) {
// Delete the blob from the dest repo // Delete the blob from the dest repo
err = bs.Delete(ctx, desc.Digest) err = bs.Delete(ctx, desc.Digest)
if err != nil { if err != nil {
t.Fatalf("Unexpected error deleting blob") t.Fatal("Unexpected error deleting blob")
} }
d, err = bs.Stat(ctx, desc.Digest) d, err = bs.Stat(ctx, desc.Digest)

View File

@ -37,7 +37,7 @@ func TestCacheSet(t *testing.T) {
} }
if len(cache.sets) != 1 || len(cache.sets[dgst]) == 0 { if len(cache.sets) != 1 || len(cache.sets[dgst]) == 0 {
t.Fatalf("Expected cache set") t.Fatal("Expected cache set")
} }
if cache.sets[dgst][0].Digest != desc.Digest { if cache.sets[dgst][0].Digest != desc.Digest {
t.Fatalf("Unexpected descriptor %v, expected %v", cache.sets[dgst][0], desc) t.Fatalf("Unexpected descriptor %v, expected %v", cache.sets[dgst][0], desc)
@ -85,7 +85,7 @@ func TestCacheError(t *testing.T) {
} }
if len(cache.sets) > 0 { if len(cache.sets) > 0 {
t.Fatalf("Set should not be called after stat error") t.Fatal("Set should not be called after stat error")
} }
} }

View File

@ -28,7 +28,7 @@ func checkBlobDescriptorCacheEmptyRepository(ctx context.Context, t *testing.T,
_, err := provider.RepositoryScoped("") _, err := provider.RepositoryScoped("")
if err == nil { if err == nil {
t.Fatalf("expected an error when asking for invalid repo") t.Fatal("expected an error when asking for invalid repo")
} }
cache, err := provider.RepositoryScoped("foo/bar") cache, err := provider.RepositoryScoped("foo/bar")
@ -49,7 +49,7 @@ func checkBlobDescriptorCacheEmptyRepository(ctx context.Context, t *testing.T,
Size: 10, Size: 10,
MediaType: "application/octet-stream", MediaType: "application/octet-stream",
}); err == nil { }); err == nil {
t.Fatalf("expected error setting value on invalid descriptor") t.Fatal("expected error setting value on invalid descriptor")
} }
if _, err := cache.Stat(ctx, ""); err != digest.ErrDigestInvalidFormat { if _, err := cache.Stat(ctx, ""); err != digest.ErrDigestInvalidFormat {

View File

@ -303,6 +303,6 @@ func TestMoveDirectory(t *testing.T) {
err = driver.Move(ctx, "/parent/dir", "/parent/other") err = driver.Move(ctx, "/parent/dir", "/parent/other")
if err == nil { if err == nil {
t.Fatalf("Moving directory /parent/dir /parent/other should have return a non-nil error\n") t.Fatal("Moving directory /parent/dir /parent/other should have return a non-nil error")
} }
} }

View File

@ -461,7 +461,7 @@ func TestDelete(t *testing.T) {
if tc.err != nil { if tc.err != nil {
if err == nil { if err == nil {
t.Fatalf("expected error") t.Fatal("expected error")
} }
if !tc.err(err) { if !tc.err(err) {
t.Fatalf("error does not match expected: %s", err) t.Fatalf("error does not match expected: %s", err)
@ -743,10 +743,10 @@ func TestWalk(t *testing.T) {
return tc.fn(fileInfo) return tc.fn(fileInfo)
}, tc.options...) }, tc.options...)
if tc.err && err == nil { if tc.err && err == nil {
t.Fatalf("expected err") t.Fatal("expected err")
} }
if !tc.err && err != nil { if !tc.err && err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
compareWalked(t, tc.expected, walked) compareWalked(t, tc.expected, walked)
}) })
@ -876,7 +876,7 @@ func TestListObjectsV2(t *testing.T) {
sort.Strings(subPaths) sort.Strings(subPaths)
sort.Strings(result) sort.Strings(result)
if !reflect.DeepEqual(subPaths, result) { if !reflect.DeepEqual(subPaths, result) {
t.Fatalf("unexpected list result") t.Fatal("unexpected list result")
} }
var walkPaths []string var walkPaths []string
@ -884,11 +884,11 @@ func TestListObjectsV2(t *testing.T) {
walkPaths = append(walkPaths, fileInfo.Path()) walkPaths = append(walkPaths, fileInfo.Path())
if fileInfo.Path() == path.Dir(subDirPath) { if fileInfo.Path() == path.Dir(subDirPath) {
if !fileInfo.IsDir() { if !fileInfo.IsDir() {
t.Fatalf("unexpected walking file info") t.Fatal("unexpected walking file info")
} }
} else { } else {
if fileInfo.IsDir() || fileInfo.Size() != int64(len(fileInfo.Path())) { if fileInfo.IsDir() || fileInfo.Size() != int64(len(fileInfo.Path())) {
t.Fatalf("unexpected walking file info") t.Fatal("unexpected walking file info")
} }
} }
return nil return nil
@ -900,7 +900,7 @@ func TestListObjectsV2(t *testing.T) {
sort.Strings(walkPaths) sort.Strings(walkPaths)
sort.Strings(subPaths) sort.Strings(subPaths)
if !reflect.DeepEqual(subPaths, walkPaths) { if !reflect.DeepEqual(subPaths, walkPaths) {
t.Fatalf("unexpected walking paths") t.Fatal("unexpected walking paths")
} }
if err := d.Delete(ctx, prefix); err != nil { if err := d.Delete(ctx, prefix); err != nil {

View File

@ -75,7 +75,7 @@ func TestWalkFileRemoved(t *testing.T) {
t.Errorf("unexpected path set during walk: %s", infos) t.Errorf("unexpected path set during walk: %s", infos)
} }
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
} }
@ -303,10 +303,10 @@ func TestWalkFallback(t *testing.T) {
return tc.fn(fileInfo) return tc.fn(fileInfo)
}, tc.options...) }, tc.options...)
if tc.err && err == nil { if tc.err && err == nil {
t.Fatalf("expected err") t.Fatal("expected err")
} }
if !tc.err && err != nil { if !tc.err && err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
compareWalked(t, tc.expected, walked) compareWalked(t, tc.expected, walked)
}) })

View File

@ -21,7 +21,7 @@ func TestSimpleRead(t *testing.T) {
} }
if n != len(content) { if n != len(content) {
t.Fatalf("random read didn't fill buffer") t.Fatal("random read didn't fill buffer")
} }
dgst, err := digest.FromReader(bytes.NewReader(content)) dgst, err := digest.FromReader(bytes.NewReader(content))
@ -47,7 +47,7 @@ func TestSimpleRead(t *testing.T) {
} }
if !verifier.Verified() { if !verifier.Verified() {
t.Fatalf("unable to verify read data") t.Fatal("unable to verify read data")
} }
} }

View File

@ -27,7 +27,7 @@ func createRegistry(t *testing.T, driver driver.StorageDriver, options ...Regist
options = append(options, EnableDelete) options = append(options, EnableDelete)
registry, err := NewRegistry(ctx, driver, options...) registry, err := NewRegistry(ctx, driver, options...)
if err != nil { if err != nil {
t.Fatalf("Failed to construct namespace") t.Fatal("Failed to construct namespace")
} }
return registry return registry
} }
@ -63,7 +63,7 @@ func allManifests(t *testing.T, manifestService distribution.ManifestService) ma
allManMap := make(map[digest.Digest]struct{}) allManMap := make(map[digest.Digest]struct{})
manifestEnumerator, ok := manifestService.(distribution.ManifestEnumerator) manifestEnumerator, ok := manifestService.(distribution.ManifestEnumerator)
if !ok { if !ok {
t.Fatalf("unable to convert ManifestService into ManifestEnumerator") t.Fatal("unable to convert ManifestService into ManifestEnumerator")
} }
err := manifestEnumerator.Enumerate(ctx, func(dgst digest.Digest) error { err := manifestEnumerator.Enumerate(ctx, func(dgst digest.Digest) error {
allManMap[dgst] = struct{}{} allManMap[dgst] = struct{}{}
@ -558,7 +558,7 @@ func TestDeletionHasEffect(t *testing.T) {
// check that the image1 manifest and all the layers are still in blobs // check that the image1 manifest and all the layers are still in blobs
if _, ok := blobs[image1.manifestDigest]; !ok { if _, ok := blobs[image1.manifestDigest]; !ok {
t.Fatalf("First manifest is missing") t.Fatal("First manifest is missing")
} }
for layer := range image1.layers { for layer := range image1.layers {
@ -751,15 +751,15 @@ func TestTaggedManifestlistWithUntaggedManifest(t *testing.T) {
} }
if _, ok := after[image1.manifestDigest]; !ok { if _, ok := after[image1.manifestDigest]; !ok {
t.Fatalf("First manifest is missing") t.Fatal("First manifest is missing")
} }
if _, ok := after[image2.manifestDigest]; !ok { if _, ok := after[image2.manifestDigest]; !ok {
t.Fatalf("Second manifest is missing") t.Fatal("Second manifest is missing")
} }
if _, ok := after[dgst]; !ok { if _, ok := after[dgst]; !ok {
t.Fatalf("Manifest list is missing") t.Fatal("Manifest list is missing")
} }
} }
@ -858,15 +858,15 @@ func TestUnTaggedManifestlistWithTaggedManifest(t *testing.T) {
afterManifests := allManifests(t, manifestService) afterManifests := allManifests(t, manifestService)
if _, ok := after[dgst]; ok { if _, ok := after[dgst]; ok {
t.Fatalf("Untagged manifestlist still exists") t.Fatal("Untagged manifestlist still exists")
} }
if _, ok := afterManifests[image1.manifestDigest]; !ok { if _, ok := afterManifests[image1.manifestDigest]; !ok {
t.Fatalf("First manifest is missing") t.Fatal("First manifest is missing")
} }
if _, ok := afterManifests[image2.manifestDigest]; !ok { if _, ok := afterManifests[image2.manifestDigest]; !ok {
t.Fatalf("Second manifest is missing") t.Fatal("Second manifest is missing")
} }
} }

View File

@ -24,7 +24,7 @@ func TestLinkedBlobStoreEnumerator(t *testing.T) {
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
rs, dgst, err := testutil.CreateRandomTarFile() rs, dgst, err := testutil.CreateRandomTarFile()
if err != nil { if err != nil {
t.Fatalf("unexpected error generating test layer file") t.Fatal("unexpected error generating test layer file")
} }
expected = append(expected, dgst.String()) expected = append(expected, dgst.String())
@ -45,7 +45,7 @@ func TestLinkedBlobStoreEnumerator(t *testing.T) {
enumerator, ok := fooEnv.repository.Blobs(fooEnv.ctx).(distribution.BlobEnumerator) enumerator, ok := fooEnv.repository.Blobs(fooEnv.ctx).(distribution.BlobEnumerator)
if !ok { if !ok {
t.Fatalf("Blobs is not a BlobEnumerator") t.Fatal("Blobs is not a BlobEnumerator")
} }
var actual []string var actual []string
@ -78,7 +78,7 @@ func TestLinkedBlobStoreCreateWithMountFrom(t *testing.T) {
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
rs, dgst, err := testutil.CreateRandomTarFile() rs, dgst, err := testutil.CreateRandomTarFile()
if err != nil { if err != nil {
t.Fatalf("unexpected error generating test layer file") t.Fatal("unexpected error generating test layer file")
} }
testLayers[dgst] = rs testLayers[dgst] = rs

View File

@ -110,7 +110,7 @@ func testManifestStorage(t *testing.T, options ...RegistryOption) {
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
rs, dgst, err := testutil.CreateRandomTarFile() rs, dgst, err := testutil.CreateRandomTarFile()
if err != nil { if err != nil {
t.Fatalf("unexpected error generating test layer file") t.Fatal("unexpected error generating test layer file")
} }
testLayers[dgst] = rs testLayers[dgst] = rs
@ -157,7 +157,7 @@ func testManifestStorage(t *testing.T, options ...RegistryOption) {
} }
if !exists { if !exists {
t.Fatalf("manifest should exist") t.Fatal("manifest should exist")
} }
fromStore, err := ms.Get(ctx, manifestDigest) fromStore, err := ms.Get(ctx, manifestDigest)
@ -167,7 +167,7 @@ func testManifestStorage(t *testing.T, options ...RegistryOption) {
fetchedManifest, ok := fromStore.(*schema2.DeserializedManifest) fetchedManifest, ok := fromStore.(*schema2.DeserializedManifest)
if !ok { if !ok {
t.Fatalf("unexpected manifest type from signedstore") t.Fatal("unexpected manifest type from signedstore")
} }
_, pl, err := fetchedManifest.Payload() _, pl, err := fetchedManifest.Payload()
if err != nil { if err != nil {
@ -194,7 +194,7 @@ func testManifestStorage(t *testing.T, options ...RegistryOption) {
byDigestManifest, ok := fetchedByDigest.(*schema2.DeserializedManifest) byDigestManifest, ok := fetchedByDigest.(*schema2.DeserializedManifest)
if !ok { if !ok {
t.Fatalf("unexpected manifest type from signedstore") t.Fatal("unexpected manifest type from signedstore")
} }
_, byDigestCanonical, err := byDigestManifest.Payload() _, byDigestCanonical, err := byDigestManifest.Payload()
@ -222,7 +222,7 @@ func testManifestStorage(t *testing.T, options ...RegistryOption) {
} }
if !bytes.Equal(receivedPL, pl) { if !bytes.Equal(receivedPL, pl) {
t.Fatalf("payloads are not equal") t.Fatal("payloads are not equal")
} }
// Test deleting manifests // Test deleting manifests
@ -233,7 +233,7 @@ func testManifestStorage(t *testing.T, options ...RegistryOption) {
exists, err = ms.Exists(ctx, dgst) exists, err = ms.Exists(ctx, dgst)
if err != nil { if err != nil {
t.Fatalf("Error querying manifest existence") t.Fatal("Error querying manifest existence")
} }
if exists { if exists {
t.Errorf("Deleted manifest should not exist") t.Errorf("Deleted manifest should not exist")
@ -262,7 +262,7 @@ func testManifestStorage(t *testing.T, options ...RegistryOption) {
exists, err = ms.Exists(ctx, dgst) exists, err = ms.Exists(ctx, dgst)
if err != nil { if err != nil {
t.Fatalf("Error querying manifest existence") t.Fatal("Error querying manifest existence")
} }
if !exists { if !exists {
t.Errorf("Restored manifest should exist") t.Errorf("Restored manifest should exist")

View File

@ -24,19 +24,19 @@ func testUploadFS(t *testing.T, numUploads int, repoName string, startedAt time.
func addUploads(ctx context.Context, t *testing.T, d driver.StorageDriver, uploadID, repo string, startedAt time.Time) { func addUploads(ctx context.Context, t *testing.T, d driver.StorageDriver, uploadID, repo string, startedAt time.Time) {
dataPath, err := pathFor(uploadDataPathSpec{name: repo, id: uploadID}) dataPath, err := pathFor(uploadDataPathSpec{name: repo, id: uploadID})
if err != nil { if err != nil {
t.Fatalf("Unable to resolve path") t.Fatal("Unable to resolve path")
} }
if err := d.PutContent(ctx, dataPath, []byte("")); err != nil { if err := d.PutContent(ctx, dataPath, []byte("")); err != nil {
t.Fatalf("Unable to write data file") t.Fatal("Unable to write data file")
} }
startedAtPath, err := pathFor(uploadStartedAtPathSpec{name: repo, id: uploadID}) startedAtPath, err := pathFor(uploadStartedAtPathSpec{name: repo, id: uploadID})
if err != nil { if err != nil {
t.Fatalf("Unable to resolve path") t.Fatal("Unable to resolve path")
} }
if err := d.PutContent(ctx, startedAtPath, []byte(startedAt.Format(time.RFC3339))); err != nil { if err := d.PutContent(ctx, startedAtPath, []byte(startedAt.Format(time.RFC3339))); err != nil {
t.Fatalf("Unable to write startedAt file") t.Fatal("Unable to write startedAt file")
} }
} }
@ -114,7 +114,7 @@ func TestPurgeOnlyUploads(t *testing.T) {
// these files aren't deleted. // these files aren't deleted.
dataPath, err := pathFor(uploadDataPathSpec{name: "test-repo", id: uuid.NewString()}) dataPath, err := pathFor(uploadDataPathSpec{name: "test-repo", id: uuid.NewString()})
if err != nil { if err != nil {
t.Fatal(err.Error()) t.Fatal(err)
} }
nonUploadPath := strings.Replace(dataPath, "_upload", "_important", -1) nonUploadPath := strings.Replace(dataPath, "_upload", "_important", -1)
if strings.Contains(nonUploadPath, "_upload") { if strings.Contains(nonUploadPath, "_upload") {

View File

@ -178,7 +178,7 @@ func TestTagLookup(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if len(tags) != 0 { if len(tags) != 0 {
t.Fatalf("Lookup returned > 0 tags from empty store") t.Fatal("Lookup returned > 0 tags from empty store")
} }
err = tagStore.Tag(ctx, "a", descA) err = tagStore.Tag(ctx, "a", descA)