@@ -2,10 +2,8 @@ package api
22
33import (
44 "bytes"
5- "io"
65 "os"
76 "strings"
8- "sync"
97 "testing"
108 "time"
119
@@ -274,46 +272,6 @@ func TestExecWithDebianMinimal(t *testing.T) {
274272 assert .Contains (t , stdout .String (), "Debian" , "Should be running Debian" )
275273 assert .Contains (t , stdout .String (), "bookworm" , "Should be Debian 12 (bookworm)" )
276274 t .Logf ("OS: %s" , strings .Split (stdout .String (), "\n " )[0 ])
277-
278- // Test TTY with TERM environment variable and window resize
279- t .Run ("TTY with TERM and resize" , func (t * testing.T ) {
280- stdinR , stdinW := io .Pipe ()
281- resizeChan := make (chan * guest.WindowSize , 1 )
282-
283- var stdoutSync syncBuffer // Thread-safe buffer
284-
285- done := make (chan struct {})
286- go func () {
287- defer close (done )
288- guest .ExecIntoInstance (ctx (), dialer2 , guest.ExecOptions {
289- Command : []string {"/bin/sh" , "-c" , "echo $TERM; stty size; read x; stty size" },
290- TTY : true ,
291- Rows : 24 ,
292- Cols : 80 ,
293- Stdin : stdinR ,
294- Stdout : & stdoutSync ,
295- ResizeChan : resizeChan ,
296- })
297- }()
298-
299- // Poll until initial output (TERM and size)
300- require .Eventually (t , func () bool {
301- out := stdoutSync .String ()
302- return strings .Contains (out , "xterm-256color" ) && strings .Contains (out , "24 80" )
303- }, 5 * time .Second , 50 * time .Millisecond , "TERM and initial size not printed" )
304-
305- // Send resize THEN stdin - gRPC stream guarantees ordering
306- resizeChan <- & guest.WindowSize {Rows : 50 , Cols : 150 }
307- stdinW .Write ([]byte ("\n " ))
308- stdinW .Close ()
309-
310- // Poll until new size appears
311- require .Eventually (t , func () bool {
312- return strings .Contains (stdoutSync .String (), "50 150" )
313- }, 5 * time .Second , 50 * time .Millisecond , "resized size not printed" )
314-
315- <- done
316- })
317275}
318276
319277// collectTestLogs collects logs from an instance (non-streaming)
@@ -343,21 +301,3 @@ func (b *outputBuffer) Write(p []byte) (n int, err error) {
343301func (b * outputBuffer ) String () string {
344302 return b .buf .String ()
345303}
346-
347- // syncBuffer is a thread-safe buffer for concurrent write/read in tests
348- type syncBuffer struct {
349- mu sync.Mutex
350- buf bytes.Buffer
351- }
352-
353- func (b * syncBuffer ) Write (p []byte ) (n int , err error ) {
354- b .mu .Lock ()
355- defer b .mu .Unlock ()
356- return b .buf .Write (p )
357- }
358-
359- func (b * syncBuffer ) String () string {
360- b .mu .Lock ()
361- defer b .mu .Unlock ()
362- return b .buf .String ()
363- }
0 commit comments