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

     1  //go:build !windows
     2  
     3  package sidecar
     4  
     5  import (
     6  	"testing"
     7  )
     8  
     9  // TestVolumeMountPointForPath tests VolumeMountPointForPath.
    10  func TestVolumeMountPointForPath(t *testing.T) {
    11  	// Define test cases.
    12  	tests := []struct {
    13  		path                     string
    14  		expectedVolumeMountPoint string
    15  	}{
    16  		{"", ""},
    17  		{"/", ""},
    18  		{"/volume", ""},
    19  		{"/volume/", ""},
    20  		{"/volume/fake", ""},
    21  		{"/whatever", ""},
    22  		{"/whatever ", ""},
    23  		{"/whatever /", ""},
    24  		{"/volumes/", ""},
    25  		{"/volumes/ ", "/volumes/ "},
    26  		{"/volumes/name", "/volumes/name"},
    27  		{"/volumes/name/", "/volumes/name"},
    28  		{"/volumes/my volume", "/volumes/my volume"},
    29  		{"/volumes/ volume", "/volumes/ volume"},
    30  		{"/volumes/name/sub", "/volumes/name"},
    31  		{"/volumes/my volume/sub", "/volumes/my volume"},
    32  		{"/volumes/name/sub/second", "/volumes/name"},
    33  		{"/volumes/my volume/sub/second sub", "/volumes/my volume"},
    34  	}
    35  
    36  	// Process test cases.
    37  	for i, test := range tests {
    38  		volumeMountPoint := VolumeMountPointForPath(test.path)
    39  		if volumeMountPoint != test.expectedVolumeMountPoint {
    40  			t.Errorf("test case %d: volume mount point does not match expected: %s != %s",
    41  				i, volumeMountPoint, test.expectedVolumeMountPoint,
    42  			)
    43  		}
    44  	}
    45  }