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