github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/pkg/system/lstat_unix_test.go (about)

     1  // +build linux freebsd
     2  
     3  package system
     4  
     5  import (
     6  	"os"
     7  	"testing"
     8  )
     9  
    10  // TestLstat tests Lstat for existing and non existing files
    11  func TestLstat(t *testing.T) {
    12  	file, invalid, _, dir := prepareFiles(t)
    13  	defer os.RemoveAll(dir)
    14  
    15  	statFile, err := Lstat(file)
    16  	if err != nil {
    17  		t.Fatal(err)
    18  	}
    19  	if statFile == nil {
    20  		t.Fatal("returned empty stat for existing file")
    21  	}
    22  
    23  	statInvalid, err := Lstat(invalid)
    24  	if err == nil {
    25  		t.Fatal("did not return error for non-existing file")
    26  	}
    27  	if statInvalid != nil {
    28  		t.Fatal("returned non-nil stat for non-existing file")
    29  	}
    30  }