...

Source file src/github.com/google/go-containerregistry/pkg/v1/remote/mount_test.go

Documentation: github.com/google/go-containerregistry/pkg/v1/remote

     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 remote
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/google/go-containerregistry/pkg/name"
    21  	"github.com/google/go-containerregistry/pkg/v1/random"
    22  	"github.com/google/go-containerregistry/pkg/v1/validate"
    23  )
    24  
    25  func TestMountableImage(t *testing.T) {
    26  	img, err := random.Image(1024, 5)
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  
    31  	ref, err := name.ParseReference("ubuntu")
    32  	if err != nil {
    33  		t.Fatal(err)
    34  	}
    35  
    36  	img = &mountableImage{
    37  		Image:     img,
    38  		Reference: ref,
    39  	}
    40  
    41  	if err := validate.Image(img); err != nil {
    42  		t.Errorf("Validate() = %v", err)
    43  	}
    44  
    45  	layers, err := img.Layers()
    46  	if err != nil {
    47  		t.Fatal(err)
    48  	}
    49  
    50  	for i, l := range layers {
    51  		if _, ok := l.(*MountableLayer); !ok {
    52  			t.Errorf("layers[%d] should be MountableLayer but isn't", i)
    53  		}
    54  	}
    55  }
    56  

View as plain text