@@ -17,9 +17,7 @@ import (
1717// For https://github.com/docker/cli/pull/1014#issuecomment-409308139
1818func TestEOFWithError (t * testing.T ) {
1919 ctx := context .TODO ()
20- cmd := "sh"
21- args := []string {"-c" , "echo hello; echo some error >&2; exit 42" }
22- c , err := New (ctx , cmd , args ... )
20+ c , err := New (ctx , "sh" , "-c" , "echo hello; echo some error >&2; exit 42" )
2321 assert .NilError (t , err )
2422 b := make ([]byte , 32 )
2523 n , err := c .Read (b )
@@ -33,9 +31,7 @@ func TestEOFWithError(t *testing.T) {
3331
3432func TestEOFWithoutError (t * testing.T ) {
3533 ctx := context .TODO ()
36- cmd := "sh"
37- args := []string {"-c" , "echo hello; echo some debug log >&2; exit 0" }
38- c , err := New (ctx , cmd , args ... )
34+ c , err := New (ctx , "sh" , "-c" , "echo hello; echo some debug log >&2; exit 0" )
3935 assert .NilError (t , err )
4036 b := make ([]byte , 32 )
4137 n , err := c .Read (b )
@@ -47,14 +43,12 @@ func TestEOFWithoutError(t *testing.T) {
4743}
4844
4945func TestCloseRunningCommand (t * testing.T ) {
50- cmd := "sh"
51- args := []string {"-c" , "while true; sleep 1; done" }
52-
46+ ctx := context .TODO ()
5347 done := make (chan struct {})
5448 defer close (done )
5549
5650 go func () {
57- c , err := New (context . TODO (), cmd , args ... )
51+ c , err := New (ctx , "sh" , "-c" , "while true; sleep 1; done" )
5852 assert .NilError (t , err )
5953 cmdConn := c .(* commandConn )
6054 assert .Check (t , process .Alive (cmdConn .cmd .Process .Pid ))
@@ -79,12 +73,10 @@ func TestCloseRunningCommand(t *testing.T) {
7973}
8074
8175func TestCloseTwice (t * testing.T ) {
82- cmd := "sh"
83- args := []string {"-c" , "echo hello; sleep 1; exit 0" }
84-
76+ ctx := context .TODO ()
8577 done := make (chan struct {})
8678 go func () {
87- c , err := New (context . TODO (), cmd , args ... )
79+ c , err := New (ctx , "sh" , "-c" , "echo hello; sleep 1; exit 0" )
8880 assert .NilError (t , err )
8981 cmdConn := c .(* commandConn )
9082 assert .Check (t , process .Alive (cmdConn .cmd .Process .Pid ))
@@ -113,12 +105,10 @@ func TestCloseTwice(t *testing.T) {
113105}
114106
115107func TestEOFTimeout (t * testing.T ) {
116- cmd := "sh"
117- args := []string {"-c" , "sleep 20" }
118-
108+ ctx := context .TODO ()
119109 done := make (chan struct {})
120110 go func () {
121- c , err := New (context . TODO (), cmd , args ... )
111+ c , err := New (ctx , "sh" , "-c" , "sleep 20" )
122112 assert .NilError (t , err )
123113 cmdConn := c .(* commandConn )
124114 assert .Check (t , process .Alive (cmdConn .cmd .Process .Pid ))
@@ -154,10 +144,8 @@ func (mockStdoutEOF) Close() error {
154144}
155145
156146func TestCloseWhileWriting (t * testing.T ) {
157- cmd := "sh"
158- args := []string {"-c" , "while true; sleep 1; done" }
159-
160- c , err := New (context .TODO (), cmd , args ... )
147+ ctx := context .TODO ()
148+ c , err := New (ctx , "sh" , "-c" , "while true; sleep 1; done" )
161149 assert .NilError (t , err )
162150 cmdConn := c .(* commandConn )
163151 assert .Check (t , process .Alive (cmdConn .cmd .Process .Pid ))
@@ -184,10 +172,8 @@ func TestCloseWhileWriting(t *testing.T) {
184172}
185173
186174func TestCloseWhileReading (t * testing.T ) {
187- cmd := "sh"
188- args := []string {"-c" , "while true; sleep 1; done" }
189-
190- c , err := New (context .TODO (), cmd , args ... )
175+ ctx := context .TODO ()
176+ c , err := New (ctx , "sh" , "-c" , "while true; sleep 1; done" )
191177 assert .NilError (t , err )
192178 cmdConn := c .(* commandConn )
193179 assert .Check (t , process .Alive (cmdConn .cmd .Process .Pid ))
0 commit comments