|
4 | 4 | use React\EventLoop\Factory as LoopFactory;
|
5 | 5 | use Clue\React\Docker\Factory;
|
6 | 6 | use Clue\React\Block;
|
| 7 | +use Clue\React\Promise\Stream; |
7 | 8 |
|
8 | 9 | class FunctionalClientTest extends TestCase
|
9 | 10 | {
|
@@ -157,6 +158,56 @@ public function testExecInspectAfterRunning($exec)
|
157 | 158 | $this->assertEquals(0, $info['ExitCode']);
|
158 | 159 | }
|
159 | 160 |
|
| 161 | + /** |
| 162 | + * @depends testStartRunning |
| 163 | + * @param string $container |
| 164 | + */ |
| 165 | + public function testExecStreamEmptyOutputWhileRunning($container) |
| 166 | + { |
| 167 | + $promise = $this->client->execCreate($container, array( |
| 168 | + 'Cmd' => array('true'), |
| 169 | + 'AttachStdout' => true, |
| 170 | + 'AttachStderr' => true, |
| 171 | + 'Tty' => true |
| 172 | + )); |
| 173 | + $exec = Block\await($promise, $this->loop); |
| 174 | + |
| 175 | + $this->assertTrue(is_array($exec)); |
| 176 | + $this->assertTrue(is_string($exec['Id'])); |
| 177 | + |
| 178 | + $stream = $this->client->execStartStream($exec['Id'], array('Tty' => true)); |
| 179 | + $stream->on('end', $this->expectCallableOnce()); |
| 180 | + |
| 181 | + $output = Block\await(Stream\buffer($stream), $this->loop); |
| 182 | + |
| 183 | + $this->assertEquals('', $output); |
| 184 | + } |
| 185 | + |
| 186 | + /** |
| 187 | + * @depends testStartRunning |
| 188 | + * @param string $container |
| 189 | + */ |
| 190 | + public function testExecStreamEmptyOutputBecauseOfDetachWhileRunning($container) |
| 191 | + { |
| 192 | + $promise = $this->client->execCreate($container, array( |
| 193 | + 'Cmd' => array('sleep', '10'), |
| 194 | + 'AttachStdout' => true, |
| 195 | + 'AttachStderr' => true, |
| 196 | + 'Tty' => true |
| 197 | + )); |
| 198 | + $exec = Block\await($promise, $this->loop); |
| 199 | + |
| 200 | + $this->assertTrue(is_array($exec)); |
| 201 | + $this->assertTrue(is_string($exec['Id'])); |
| 202 | + |
| 203 | + $stream = $this->client->execStartStream($exec['Id'], array('Tty' => true, 'Detach' => true)); |
| 204 | + $stream->on('end', $this->expectCallableOnce()); |
| 205 | + |
| 206 | + $output = Block\await(Stream\buffer($stream), $this->loop); |
| 207 | + |
| 208 | + $this->assertEquals('', $output); |
| 209 | + } |
| 210 | + |
160 | 211 | /**
|
161 | 212 | * @depends testStartRunning
|
162 | 213 | * @param string $container
|
|
0 commit comments