github.com/rentongzhang/docker@v1.8.2-rc1/pkg/system/lstat_test.go (about)

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