|
@@ 203-222 (lines=20) @@
|
| 200 |
|
$this->assertNull($manager->run($container, null, [], true)); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
public function testAttach() |
| 204 |
|
{ |
| 205 |
|
$container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/bash', '-c', 'echo -n "output"']]); |
| 206 |
|
$manager = $this->getManager(); |
| 207 |
|
|
| 208 |
|
$type = 0; |
| 209 |
|
$output = ""; |
| 210 |
|
|
| 211 |
|
$manager->create($container); |
| 212 |
|
$response = $manager->attach($container, function ($log, $stdtype) use (&$type, &$output) { |
| 213 |
|
$type = $stdtype; |
| 214 |
|
$output = $log; |
| 215 |
|
}); |
| 216 |
|
$manager->start($container); |
| 217 |
|
|
| 218 |
|
$response->getBody()->getContents(); |
| 219 |
|
|
| 220 |
|
$this->assertEquals(1, $type); |
| 221 |
|
$this->assertEquals('output', $output); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
public function testAttachStderr() |
| 225 |
|
{ |
|
@@ 224-243 (lines=20) @@
|
| 221 |
|
$this->assertEquals('output', $output); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
public function testAttachStderr() |
| 225 |
|
{ |
| 226 |
|
$container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/bash', '-c', 'echo -n "error" 1>&2']]); |
| 227 |
|
$manager = $this->getManager(); |
| 228 |
|
|
| 229 |
|
$type = 0; |
| 230 |
|
$output = ""; |
| 231 |
|
|
| 232 |
|
$manager->create($container); |
| 233 |
|
$response = $manager->attach($container, function ($log, $stdtype) use (&$type, &$output) { |
| 234 |
|
$type = $stdtype; |
| 235 |
|
$output = $log; |
| 236 |
|
}); |
| 237 |
|
$manager->start($container); |
| 238 |
|
|
| 239 |
|
$response->getBody()->getContents(); |
| 240 |
|
|
| 241 |
|
$this->assertEquals(2, $type); |
| 242 |
|
$this->assertEquals('error', $output); |
| 243 |
|
} |
| 244 |
|
|
| 245 |
|
/** |
| 246 |
|
* Not sure how to reliably test that we actually waited for the container |