...

Source file src/github.com/google/go-containerregistry/pkg/v1/layout/read_test.go

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

     1  // Copyright 2019 The original author or authors
     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 layout
    16  
    17  import (
    18  	"testing"
    19  )
    20  
    21  func TestRead(t *testing.T) {
    22  	lp, err := FromPath(testPath)
    23  	if err != nil {
    24  		t.Fatalf("FromPath() = %v", err)
    25  	}
    26  	if testPath != lp.path() {
    27  		t.Errorf("unexpected path %s", lp.path())
    28  	}
    29  }
    30  
    31  func TestReadErrors(t *testing.T) {
    32  	if _, err := FromPath(bogusPath); err == nil {
    33  		t.Errorf("FromPath(%s) = nil, expected err", bogusPath)
    34  	}
    35  
    36  	// Found this here:
    37  	// https://github.com/golang/go/issues/24195
    38  	invalidPath := "double-null-padded-string\x00\x00"
    39  	if _, err := FromPath(invalidPath); err == nil {
    40  		t.Errorf("FromPath(%s) = nil, expected err", bogusPath)
    41  	}
    42  }
    43  

View as plain text