github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/simplefs/platform_test.go (about)

     1  package simplefs
     2  
     3  import (
     4  	"runtime"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func TestLimitFilenameLengthForWindowsDownloads(t *testing.T) {
    12  	if runtime.GOOS != "windows" {
    13  		return
    14  	}
    15  
    16  	{
    17  		fn := strings.Repeat("a", 251) + ".exe"
    18  		limited := limitFilenameLengthForWindowsDownloads(fn)
    19  		require.True(t, strings.HasSuffix(limited, ".exe"))
    20  		require.True(t, len(limited) <= 200)
    21  	}
    22  
    23  	{
    24  		fn := strings.Repeat("a", 100) + ".exe"
    25  		limited := limitFilenameLengthForWindowsDownloads(fn)
    26  		require.True(t, fn == limited)
    27  	}
    28  }