github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/internal/fileutils/fileutils_win_test.go (about)

     1  // +build windows
     2  
     3  package fileutils
     4  
     5  import (
     6  	"path/filepath"
     7  	"testing"
     8  )
     9  
    10  func TestIsExecutable(t *testing.T) {
    11  	tests := []struct {
    12  		name string
    13  		path string
    14  	}{
    15  		{"exe lower case", filepath.FromSlash("/a/test-a.exe")},
    16  		{"exe uppper case", filepath.FromSlash("/a/test-a.EXE")},
    17  		{"bat lower case", filepath.FromSlash("/a/test-a.bat")},
    18  		{"bat upper case", filepath.FromSlash("/a/test-a.BAT")},
    19  	}
    20  
    21  	for _, tc := range tests {
    22  		t.Run(tc.name, func(tt *testing.T) {
    23  			if !IsExecutable(tc.path) {
    24  				tt.Errorf("expected %s to be executable", tc.path)
    25  			}
    26  		})
    27  	}
    28  
    29  	invalid := filepath.FromSlash("/d/e/test-a.txt")
    30  	if IsExecutable(invalid) {
    31  		t.Errorf("%s should not be executable", invalid)
    32  	}
    33  }
    34