...

Source file src/github.com/google/go-containerregistry/pkg/v1/empty/image_test.go

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

     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 empty
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/google/go-containerregistry/pkg/v1/validate"
    21  )
    22  
    23  func TestImage(t *testing.T) {
    24  	if err := validate.Image(Image); err != nil {
    25  		t.Fatalf("validate.Image(empty.Image) = %v", err)
    26  	}
    27  }
    28  
    29  func TestManifestAndConfig(t *testing.T) {
    30  	manifest, err := Image.Manifest()
    31  	if err != nil {
    32  		t.Fatalf("Error loading manifest: %v", err)
    33  	}
    34  	if got, want := len(manifest.Layers), 0; got != want {
    35  		t.Fatalf("num layers; got %v, want %v", got, want)
    36  	}
    37  
    38  	config, err := Image.ConfigFile()
    39  	if err != nil {
    40  		t.Fatalf("Error loading config file: %v", err)
    41  	}
    42  	if got, want := len(config.RootFS.DiffIDs), 0; got != want {
    43  		t.Fatalf("num diff ids; got %v, want %v", got, want)
    44  	}
    45  	if got, want := config.RootFS.Type, "layers"; got != want {
    46  		t.Fatalf("rootfs type; got %v, want %v", got, want)
    47  	}
    48  }
    49  

View as plain text