mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: batch 06 of refactoring CLI tests not to use PTY (#25990)
Part of [coder/internal#1400](https://github.com/coder/internal/issues/1400) Batch of refactored CLI tests to avoid creating PTYs.
This commit is contained in:
@@ -85,6 +85,18 @@ func NewAttachedToInvocation(t *testing.T, invocation *serpent.Invocation) *Expe
|
||||
return e
|
||||
}
|
||||
|
||||
func NewPiped(t *testing.T) (*Expecter, io.Writer) {
|
||||
r, w := io.Pipe()
|
||||
e := New(t, r, "cmd")
|
||||
|
||||
t.Cleanup(func() {
|
||||
// Close writer here at the end of the test to ensure we don't leak goroutines reading from the pipe.
|
||||
_ = w.Close()
|
||||
e.Close("test end")
|
||||
})
|
||||
return e, w
|
||||
}
|
||||
|
||||
type Expecter struct {
|
||||
t *testing.T
|
||||
out *stdbuf
|
||||
|
||||
Reference in New Issue
Block a user