...

Source file src/github.com/google/go-containerregistry/internal/compare/index_test.go

Documentation: github.com/google/go-containerregistry/internal/compare

     1  // Copyright 2019 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 compare
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/google/go-containerregistry/pkg/v1/mutate"
    21  	"github.com/google/go-containerregistry/pkg/v1/random"
    22  	"github.com/google/go-containerregistry/pkg/v1/types"
    23  )
    24  
    25  func TestDifferentIndexes(t *testing.T) {
    26  	a, err := random.Index(100, 3, 3)
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  	b, err := random.Index(100, 2, 2)
    31  	if err != nil {
    32  		t.Fatal(err)
    33  	}
    34  
    35  	b = mutate.IndexMediaType(b, types.DockerManifestList)
    36  
    37  	if err := Indexes(a, b); err == nil {
    38  		t.Errorf("got nil err, should have something")
    39  	}
    40  }
    41  
    42  func TestEqualIndexes(t *testing.T) {
    43  	a, err := random.Index(100, 2, 2)
    44  	if err != nil {
    45  		t.Fatal(err)
    46  	}
    47  
    48  	if err := Indexes(a, a); err != nil {
    49  		t.Errorf("got err: %v", err)
    50  	}
    51  }
    52  

View as plain text