1
0
mirror of https://github.com/distribution/distribution synced 2024-12-25 15:05:51 +01:00

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

@ -336,7 +336,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) {
}
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

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

@ -394,7 +394,7 @@ func TestBlobExistsNoContentLength(t *testing.T) {
t.Fatal(err)
}
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")
if err == nil {
t.Fatalf("Expected an error")
t.Fatal("Expected an error")
}
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")
if err != nil {
t.Fatalf("Expected no error")
t.Fatal("Expected no error")
}
if desc.Digest != dgst {
t.Fatalf("Unexpected digest")
t.Fatal("Unexpected digest")
}
}
@ -1657,7 +1657,7 @@ func TestCatalog(t *testing.T) {
}
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 {
t.Fatalf("Got wrong number of repos")
t.Fatal("Got wrong number of repos")
}
numFilled, err = r.Repositories(ctx, entries, "baz")
@ -1698,7 +1698,7 @@ func TestCatalogInParts(t *testing.T) {
}
if numFilled != 1 {
t.Fatalf("Got wrong number of repos")
t.Fatal("Got wrong number of repos")
}
}

@ -164,7 +164,7 @@ func TestWithResponseWriter(t *testing.T) {
rw.(http.Flusher).Flush()
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

@ -6,7 +6,7 @@ func TestVersionContext(t *testing.T) {
ctx := Background()
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"

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

@ -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)
}
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))) {
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 err == nil {
t.Fatalf("bad content type should have produced error")
t.Fatal("bad content type should have produced error")
}
} else {
if err != nil {

@ -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)
}
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))) {
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 err == nil {
t.Fatalf("bad content type should have produced error")
t.Fatal("bad content type should have produced error")
}
} else {
if err != nil {

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

@ -179,7 +179,7 @@ func TestHTTPSink(t *testing.T) {
}
} else {
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)
}

@ -178,12 +178,12 @@ func checkTestRepository(t *testing.T, repository distribution.Repository, remov
sm, err := schema2.FromStruct(m)
if err != nil {
t.Fatal(err.Error())
t.Fatal(err)
}
manifests, err := repository.Manifests(ctx)
if err != nil {
t.Fatal(err.Error())
t.Fatal(err)
}
var digestPut digest.Digest
@ -193,12 +193,12 @@ func checkTestRepository(t *testing.T, repository distribution.Repository, remov
_, canonical, err := sm.Payload()
if err != nil {
t.Fatal(err.Error())
t.Fatal(err)
}
dgst := digest.FromBytes(canonical)
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 {

@ -51,7 +51,7 @@ func TestEventQueue(t *testing.T) {
}
if !ts.closed {
t.Fatalf("sink should have been closed")
t.Fatal("sink should have been closed")
}
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.
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
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 {
t.Fatalf("error should be ErrSinkClosed")
t.Fatal("error should be ErrSinkClosed")
}
}

@ -169,7 +169,7 @@ func TestErrorsManagement(t *testing.T) {
e1 = ErrorCodeTest3.WithArgs("test1")
e2 := e1.WithArgs("test2")
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` {
t.Fatalf("e2 had wrong message: %q", e2.Message)
@ -180,7 +180,7 @@ func TestErrorsManagement(t *testing.T) {
e1 = ErrorCodeTest3.WithDetail("stuff1")
e2 = e1.WithDetail("stuff2")
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` {
t.Fatalf("e2 had wrong detail: %q", e2.Detail)

@ -119,7 +119,7 @@ func TestCatalogAPI(t *testing.T) {
// No pagination should be returned
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 {
@ -157,7 +157,7 @@ func TestCatalogAPI(t *testing.T) {
// fail if there's no pagination
link := resp.Header.Get("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))
@ -221,7 +221,7 @@ func TestCatalogAPI(t *testing.T) {
// fail if there's no pagination
link = resp.Header.Get("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
link = resp.Header.Get("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)
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])
urlValues := linkURL.Query()
@ -1037,7 +1037,7 @@ func testBlobAPI(t *testing.T, env *testEnv, args blobArgs) *testEnv {
}
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)
layerURL, err := env.builder.BuildBlobURL(ref)
if err != nil {
t.Fatal(err.Error())
t.Fatal(err)
}
// ---------------
// Delete a layer
@ -1201,7 +1201,7 @@ func TestDeleteDisabled(t *testing.T) {
ref, _ := reference.WithDigest(imageName, layerDigest)
layerURL, err := env.builder.BuildBlobURL(ref)
if err != nil {
t.Fatalf("Error building blob URL")
t.Fatal("Error building blob URL")
}
uploadURLBase, _ := startPushLayer(t, env, imageName)
pushLayer(t, env.builder, imageName, layerDigest, uploadURLBase, layerFile)
@ -1229,7 +1229,7 @@ func TestDeleteReadOnly(t *testing.T) {
ref, _ := reference.WithDigest(imageName, layerDigest)
layerURL, err := env.builder.BuildBlobURL(ref)
if err != nil {
t.Fatalf("Error building blob URL")
t.Fatal("Error building blob URL")
}
uploadURLBase, _ := startPushLayer(t, env, imageName)
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) {
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) {
t.Fatalf("manifests do not match")
t.Fatal("manifests do not match")
}
// 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) {
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) {
t.Fatalf("manifests do not match")
t.Fatal("manifests do not match")
}
// 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)
if err != nil {
t.Fatalf("error generating sha256 digest of body")
t.Fatal("error generating sha256 digest of body")
}
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)
if err != nil {
t.Fatalf("error generating sha256 digest of body")
t.Fatal("error generating sha256 digest of body")
}
checkHeaders(t, resp, http.Header{
@ -2540,7 +2540,7 @@ func checkBodyHasErrorCodes(t *testing.T, msg string, resp *http.Response, error
}
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-
@ -2843,7 +2843,7 @@ func TestProxyManifestGetByTag(t *testing.T) {
// Create another manifest in the remote with the same image/tag pair
newDigest := createRepository(truthEnv, t, imageName.Name(), tag)
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

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

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

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

@ -98,7 +98,7 @@ func TestGet(t *testing.T) {
}
if !reflect.DeepEqual(local, remoteDesc) {
t.Fatalf("unexpected descriptor pulled through")
t.Fatal("unexpected descriptor pulled through")
}
// Manually overwrite remote tag
@ -134,12 +134,12 @@ func TestGet(t *testing.T) {
_, err = proxyTags.localTags.Get(ctx, remoteTag)
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)
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)

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

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

@ -37,7 +37,7 @@ func TestCacheSet(t *testing.T) {
}
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 {
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 {
t.Fatalf("Set should not be called after stat error")
t.Fatal("Set should not be called after stat error")
}
}

@ -28,7 +28,7 @@ func checkBlobDescriptorCacheEmptyRepository(ctx context.Context, t *testing.T,
_, err := provider.RepositoryScoped("")
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")
@ -49,7 +49,7 @@ func checkBlobDescriptorCacheEmptyRepository(ctx context.Context, t *testing.T,
Size: 10,
MediaType: "application/octet-stream",
}); 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 {

@ -303,6 +303,6 @@ func TestMoveDirectory(t *testing.T) {
err = driver.Move(ctx, "/parent/dir", "/parent/other")
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")
}
}

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

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

@ -21,7 +21,7 @@ func TestSimpleRead(t *testing.T) {
}
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))
@ -47,7 +47,7 @@ func TestSimpleRead(t *testing.T) {
}
if !verifier.Verified() {
t.Fatalf("unable to verify read data")
t.Fatal("unable to verify read data")
}
}

@ -27,7 +27,7 @@ func createRegistry(t *testing.T, driver driver.StorageDriver, options ...Regist
options = append(options, EnableDelete)
registry, err := NewRegistry(ctx, driver, options...)
if err != nil {
t.Fatalf("Failed to construct namespace")
t.Fatal("Failed to construct namespace")
}
return registry
}
@ -63,7 +63,7 @@ func allManifests(t *testing.T, manifestService distribution.ManifestService) ma
allManMap := make(map[digest.Digest]struct{})
manifestEnumerator, ok := manifestService.(distribution.ManifestEnumerator)
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 {
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
if _, ok := blobs[image1.manifestDigest]; !ok {
t.Fatalf("First manifest is missing")
t.Fatal("First manifest is missing")
}
for layer := range image1.layers {
@ -751,15 +751,15 @@ func TestTaggedManifestlistWithUntaggedManifest(t *testing.T) {
}
if _, ok := after[image1.manifestDigest]; !ok {
t.Fatalf("First manifest is missing")
t.Fatal("First manifest is missing")
}
if _, ok := after[image2.manifestDigest]; !ok {
t.Fatalf("Second manifest is missing")
t.Fatal("Second manifest is missing")
}
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)
if _, ok := after[dgst]; ok {
t.Fatalf("Untagged manifestlist still exists")
t.Fatal("Untagged manifestlist still exists")
}
if _, ok := afterManifests[image1.manifestDigest]; !ok {
t.Fatalf("First manifest is missing")
t.Fatal("First manifest is missing")
}
if _, ok := afterManifests[image2.manifestDigest]; !ok {
t.Fatalf("Second manifest is missing")
t.Fatal("Second manifest is missing")
}
}

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

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

@ -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) {
dataPath, err := pathFor(uploadDataPathSpec{name: repo, id: uploadID})
if err != nil {
t.Fatalf("Unable to resolve path")
t.Fatal("Unable to resolve path")
}
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})
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 {
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.
dataPath, err := pathFor(uploadDataPathSpec{name: "test-repo", id: uuid.NewString()})
if err != nil {
t.Fatal(err.Error())
t.Fatal(err)
}
nonUploadPath := strings.Replace(dataPath, "_upload", "_important", -1)
if strings.Contains(nonUploadPath, "_upload") {

@ -178,7 +178,7 @@ func TestTagLookup(t *testing.T) {
t.Fatal(err)
}
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)