@@ -613,8 +613,8 @@ def test_logs(self):
613
613
BUSYBOX , 'echo {0}' .format (snippet )
614
614
)
615
615
id = container ['Id' ]
616
- self .client .start (id )
617
616
self .tmp_containers .append (id )
617
+ self .client .start (id )
618
618
exitcode = self .client .wait (id )
619
619
self .assertEqual (exitcode , 0 )
620
620
logs = self .client .logs (id )
@@ -627,43 +627,56 @@ def test_logs_tail_option(self):
627
627
BUSYBOX , 'echo "{0}"' .format (snippet )
628
628
)
629
629
id = container ['Id' ]
630
- self .client .start (id )
631
630
self .tmp_containers .append (id )
631
+ self .client .start (id )
632
632
exitcode = self .client .wait (id )
633
633
self .assertEqual (exitcode , 0 )
634
634
logs = self .client .logs (id , tail = 1 )
635
- self .assertEqual (logs , ( 'Line2\n ' ) .encode (encoding = 'ascii' ))
635
+ self .assertEqual (logs , 'Line2\n ' .encode (encoding = 'ascii' ))
636
636
637
- # def test_logs_streaming(self):
638
- # snippet = 'Flowering Nights (Sakuya Iyazoi)'
639
- # container = self.client.create_container(
640
- # BUSYBOX, 'echo {0}'.format(snippet)
641
- # )
642
- # id = container['Id']
643
- # self.client.start (id)
644
- # self.tmp_containers.append (id)
645
- # logs = bytes() if six.PY3 else str ()
646
- # for chunk in self.client.logs(id, stream=True):
647
- # logs += chunk
637
+ def test_logs_streaming (self ):
638
+ snippet = 'Flowering Nights (Sakuya Iyazoi)'
639
+ container = self .client .create_container (
640
+ BUSYBOX , 'echo {0}' .format (snippet )
641
+ )
642
+ id = container ['Id' ]
643
+ self .tmp_containers . append (id )
644
+ self .client . start (id )
645
+ logs = six .binary_type ()
646
+ for chunk in self .client .logs (id , stream = True ):
647
+ logs += chunk
648
648
649
- # exitcode = self.client.wait(id)
650
- # self.assertEqual(exitcode, 0)
649
+ exitcode = self .client .wait (id )
650
+ self .assertEqual (exitcode , 0 )
651
651
652
- # self.assertEqual(logs, (snippet + '\n').encode(encoding='ascii'))
652
+ self .assertEqual (logs , (snippet + '\n ' ).encode (encoding = 'ascii' ))
653
653
654
654
def test_logs_with_dict_instead_of_id (self ):
655
655
snippet = 'Flowering Nights (Sakuya Iyazoi)'
656
656
container = self .client .create_container (
657
657
BUSYBOX , 'echo {0}' .format (snippet )
658
658
)
659
659
id = container ['Id' ]
660
- self .client .start (id )
661
660
self .tmp_containers .append (id )
661
+ self .client .start (id )
662
662
exitcode = self .client .wait (id )
663
663
self .assertEqual (exitcode , 0 )
664
664
logs = self .client .logs (container )
665
665
self .assertEqual (logs , (snippet + '\n ' ).encode (encoding = 'ascii' ))
666
666
667
+ def test_logs_with_tail_0 (self ):
668
+ snippet = 'Flowering Nights (Sakuya Iyazoi)'
669
+ container = self .client .create_container (
670
+ BUSYBOX , 'echo "{0}"' .format (snippet )
671
+ )
672
+ id = container ['Id' ]
673
+ self .tmp_containers .append (id )
674
+ self .client .start (id )
675
+ exitcode = self .client .wait (id )
676
+ self .assertEqual (exitcode , 0 )
677
+ logs = self .client .logs (id , tail = 0 )
678
+ self .assertEqual (logs , '' .encode (encoding = 'ascii' ))
679
+
667
680
668
681
class DiffTest (api_test .BaseTestCase ):
669
682
def test_diff (self ):
0 commit comments