...

Source file src/github.com/Microsoft/go-winio/pkg/fs/fs_windows_test.go

Documentation: github.com/Microsoft/go-winio/pkg/fs

     1  package fs
     2  
     3  import (
     4  	"errors"
     5  	"os"
     6  	"testing"
     7  )
     8  
     9  func TestGetFSTypeOfKnownDrive(t *testing.T) {
    10  	fsType, err := GetFileSystemType("C:\\")
    11  	if err != nil {
    12  		t.Fatal(err)
    13  	}
    14  
    15  	if fsType == "" {
    16  		t.Fatal("No filesystem type name returned")
    17  	}
    18  }
    19  
    20  func TestGetFSTypeOfInvalidPath(t *testing.T) {
    21  	_, err := GetFileSystemType("7:\\")
    22  	if !errors.Is(err, ErrInvalidPath) {
    23  		t.Fatalf("Expected `ErrInvalidPath`, got %v", err)
    24  	}
    25  }
    26  
    27  func TestGetFSTypeOfValidButAbsentDrive(t *testing.T) {
    28  	drive := ""
    29  	for _, letter := range "abcdefghijklmnopqrstuvwxyz" {
    30  		possibleDrive := string(letter) + ":\\"
    31  		if _, err := os.Stat(possibleDrive); os.IsNotExist(err) {
    32  			drive = possibleDrive
    33  			break
    34  		}
    35  	}
    36  	if drive == "" {
    37  		t.Skip("Every possible drive exists")
    38  	}
    39  
    40  	_, err := GetFileSystemType(drive)
    41  	if err == nil {
    42  		t.Fatalf("GetFileSystemType %s unexpectedly succeeded", drive)
    43  	}
    44  	if !os.IsNotExist(err) {
    45  		t.Fatalf("GetFileSystemType %s failed with %v, expected 'ErrNotExist' or similar", drive, err)
    46  	}
    47  }
    48  

View as plain text