github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/filesystem/mutagen_test.go (about)

     1  package filesystem
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  )
     7  
     8  const (
     9  	// testingDirectoryName is the name of a testing directory to create within
    10  	// the Mutagen data directory.
    11  	testingDirectoryName = "testing"
    12  )
    13  
    14  // TestMutagen tests the Mutagen data directory creation function.
    15  func TestMutagen(t *testing.T) {
    16  	// Attempt to create the testing subdirectory and defer its removal.
    17  	path, err := Mutagen(true, testingDirectoryName)
    18  	if err != nil {
    19  		t.Fatal("unable to create testing subdirectory:", err)
    20  	}
    21  	defer os.RemoveAll(path)
    22  
    23  	// Ensure it exists and is a directory.
    24  	if info, err := os.Lstat(path); err != nil {
    25  		t.Fatal("unable to probe testing subdirectory:", err)
    26  	} else if !info.IsDir() {
    27  		t.Error("Mutagen subpath is not a directory")
    28  	}
    29  }