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

     1  package daemon
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"testing"
     7  )
     8  
     9  // TestSubpath test that subpath succeeds and creates the daemon subdirectory.
    10  func TestSubpath(t *testing.T) {
    11  	// Compute a random subpath.
    12  	path, err := subpath("something")
    13  	if err != nil {
    14  		t.Fatal("unable to compute subpath:", err)
    15  	}
    16  
    17  	// Ensure that the daemon subdirectory has been created.
    18  	if s, err := os.Lstat(filepath.Dir(path)); err != nil {
    19  		t.Fatal("unable to verify that daemon subdirectory exists:", err)
    20  	} else if !s.IsDir() {
    21  		t.Error("daemon subdirectory is not a directory")
    22  	}
    23  }
    24  
    25  // TestLockPath tests that lockPath succeeds.
    26  func TestLockPath(t *testing.T) {
    27  	if path, err := lockPath(); err != nil {
    28  		t.Fatal("unable to compute lock path:", err)
    29  	} else if path == "" {
    30  		t.Error("empty lock path returned")
    31  	}
    32  }
    33  
    34  // TestEndpointPath tests that EndpointPath succeeds.
    35  func TestEndpointPath(t *testing.T) {
    36  	if path, err := EndpointPath(); err != nil {
    37  		t.Fatal("unable to compute IPC endpoint path:", err)
    38  	} else if path == "" {
    39  		t.Error("empty IPC endpoint path returned")
    40  	}
    41  }