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

     1  package filesystem
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"strings"
     7  	"testing"
     8  )
     9  
    10  // TestOpenLongPath verifies that calling Open succeeds on a directory whose
    11  // path length exceeds the default path length limit on Windows.
    12  func TestOpenLongPath(t *testing.T) {
    13  	// Create a directory (in a temporary directory that will be automatically
    14  	// removed) with a name that will exceed the Windows path length limit.
    15  	longDirectoryName := strings.Repeat("d", windowsLongPathTestingLength)
    16  	longtemporaryDirectoryPath := filepath.Join(t.TempDir(), longDirectoryName)
    17  	if err := os.Mkdir(longtemporaryDirectoryPath, 0700); err != nil {
    18  		t.Fatal("unable to create test directory with long name:", err)
    19  	}
    20  
    21  	// Attempt to open the directory and ensure doing so succeeds.
    22  	directory, _, err := Open(longtemporaryDirectoryPath, false)
    23  	if err != nil {
    24  		t.Fatal("unable to open directory with long path:", err)
    25  	}
    26  	directory.Close()
    27  }