@@ -3,24 +3,30 @@ import { describe, expect, it } from "vite-plus/test";
33import { resolveDesktopAppControlAddress } from "./desktopAppControl.ts" ;
44
55describe ( "resolveDesktopAppControlAddress" , ( ) => {
6- it ( "keeps Unix socket paths short and separates desktop state directories" , ( ) => {
6+ it . each ( [
7+ [ "linux" , "/tmp" , "/tmp/t3code-1000" , 107 ] ,
8+ [ "linux" , "/var/tmp/custom" , "/var/tmp/custom/t3code-1000" , 107 ] ,
9+ [ "linux" , `/tmp/${ "x" . repeat ( 120 ) } ` , "/tmp/t3code-1000" , 107 ] ,
10+ [ "darwin" , `/tmp/${ "é" . repeat ( 30 ) } ` , "/tmp/t3code-1000" , 103 ] ,
11+ [ "darwin" , `/tmp/${ "x" . repeat ( 56 ) } ` , `/tmp/${ "x" . repeat ( 56 ) } /t3code-1000` , 103 ] ,
12+ ] as const ) ( "keeps %s sockets short under %s" , ( platform , tempDir , directory , maxBytes ) => {
713 const first = resolveDesktopAppControlAddress ( {
814 stateDir : `/home/user/${ "long/" . repeat ( 40 ) } userdata` ,
9- platform : "linux" ,
10- tempDir : "/tmp" ,
15+ platform,
16+ tempDir,
1117 userId : 1000 ,
1218 joinPath : ( ...segments ) => segments . join ( "/" ) ,
1319 } ) ;
1420 const second = resolveDesktopAppControlAddress ( {
1521 stateDir : "/home/user/.t3/other/userdata" ,
16- platform : "linux" ,
17- tempDir : "/tmp" ,
22+ platform,
23+ tempDir,
1824 userId : 1000 ,
1925 joinPath : ( ...segments ) => segments . join ( "/" ) ,
2026 } ) ;
2127
22- expect ( first . directory ) . toBe ( "/tmp/t3code-1000" ) ;
23- expect ( first . address . length ) . toBeLessThan ( 108 ) ;
28+ expect ( new TextEncoder ( ) . encode ( first . address ) . byteLength ) . toBeLessThanOrEqual ( maxBytes ) ;
29+ expect ( first . directory ) . toBe ( directory ) ;
2430 expect ( first . address ) . not . toBe ( second . address ) ;
2531 } ) ;
2632
0 commit comments