cuelabs.dev/go/oci/ociregistry@v0.0.0-20240906074133-82eb438dd565/ociserver/compatibility_test.go (about)

     1  // Copyright 2018 Google LLC All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package ociserver_test
    16  
    17  //
    18  //import (
    19  //	"bytes"
    20  //	"net/http/httptest"
    21  //	"strings"
    22  //	"testing"
    23  //
    24  //	"github.com/google/go-containerregistry/pkg/name"
    25  //	"github.com/google/go-containerregistry/pkg/registry"
    26  //	"github.com/google/go-containerregistry/pkg/v1/random"
    27  //	"github.com/google/go-containerregistry/pkg/v1/remote"
    28  //	"github.com/google/go-containerregistry/pkg/v1/tarball"
    29  //)
    30  //
    31  //func TestPushAndPullContainer(t *testing.T) {
    32  //	s := httptest.NewServer(registry.New())
    33  //	defer s.Close()
    34  //
    35  //	r := strings.TrimPrefix(s.URL, "http://") + "/foo:latest"
    36  //	d, err := name.NewTag(r)
    37  //	if err != nil {
    38  //		t.Fatalf("Unable to create tag: %v", err)
    39  //	}
    40  //
    41  //	i, err := random.Image(1024, 1)
    42  //	if err != nil {
    43  //		t.Fatalf("Unable to make random image: %v", err)
    44  //	}
    45  //
    46  //	if err := remote.Write(d, i); err != nil {
    47  //		t.Fatalf("Error writing image: %v", err)
    48  //	}
    49  //
    50  //	ref, err := name.ParseReference(r)
    51  //	if err != nil {
    52  //		t.Fatalf("Error parsing tag: %v", err)
    53  //	}
    54  //
    55  //	ri, err := remote.Image(ref)
    56  //	if err != nil {
    57  //		t.Fatalf("Error reading image: %v", err)
    58  //	}
    59  //
    60  //	b := &bytes.Buffer{}
    61  //	if err := tarball.Write(ref, ri, b); err != nil {
    62  //		t.Fatalf("Error writing image to tarball: %v", err)
    63  //	}
    64  //}