github.com/containerd/Containerd@v1.4.13/runtime/v2/shim_windows_test.go (about)

     1  /*
     2     Copyright The containerd Authors.
     3  
     4     Licensed under the Apache License, Version 2.0 (the "License");
     5     you may not use this file except in compliance with the License.
     6     You may obtain a copy of the License at
     7  
     8         http://www.apache.org/licenses/LICENSE-2.0
     9  
    10     Unless required by applicable law or agreed to in writing, software
    11     distributed under the License is distributed on an "AS IS" BASIS,
    12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13     See the License for the specific language governing permissions and
    14     limitations under the License.
    15  */
    16  
    17  package v2
    18  
    19  import (
    20  	"context"
    21  	"os"
    22  	"testing"
    23  
    24  	"github.com/pkg/errors"
    25  )
    26  
    27  func TestCheckCopyShimLogError(t *testing.T) {
    28  	ctx, cancel := context.WithCancel(context.Background())
    29  	defer cancel()
    30  	testError := errors.New("test error")
    31  
    32  	if err := checkCopyShimLogError(ctx, nil); err != nil {
    33  		t.Fatalf("should return the actual error except ErrNotExist, but %v", err)
    34  	}
    35  	if err := checkCopyShimLogError(ctx, testError); err != testError {
    36  		t.Fatalf("should return the actual error except ErrNotExist, but %v", err)
    37  	}
    38  	if err := checkCopyShimLogError(ctx, os.ErrNotExist); err != nil {
    39  		t.Fatalf("should return nil for ErrNotExist, but %v", err)
    40  	}
    41  }