Skip to content

Commit a4b37ca

Browse files
committed
more tests
1 parent 0756cab commit a4b37ca

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

tests/test_simple.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ def test_unix_sockets(self):
598598
node.execute('postgres', 'select 1')
599599
node.safe_psql('postgres', 'select 1')
600600

601-
r = node.replicate('r').start()
602-
r.execute('postgres', 'select 1')
603-
r.safe_psql('postgres', 'select 1')
601+
with node.replicate('r').start() as r:
602+
r.execute('postgres', 'select 1')
603+
r.safe_psql('postgres', 'select 1')
604604

605605
def test_auto_name(self):
606606
with get_new_node().init(allow_streaming=True).start() as m:
@@ -617,6 +617,29 @@ def test_auto_name(self):
617617
self.assertTrue('testgres' in m.name)
618618
self.assertTrue('testgres' in r.name)
619619

620+
def test_file_tail(self):
621+
from testgres.utils import file_tail
622+
623+
s1 = "the quick brown fox jumped over that lazy dog\n"
624+
s2 = "abc\n"
625+
s3 = "def\n"
626+
627+
with tempfile.NamedTemporaryFile(mode='r+', delete=True) as f:
628+
for i in range(1, 5000):
629+
f.write(s1)
630+
f.write(s2)
631+
f.write(s3)
632+
633+
f.seek(0)
634+
lines = file_tail(f, 3)
635+
self.assertEqual(lines[0], s1)
636+
self.assertEqual(lines[1], s2)
637+
self.assertEqual(lines[2], s3)
638+
639+
f.seek(0)
640+
lines = file_tail(f, 1)
641+
self.assertEqual(lines[0], s3)
642+
620643
def test_isolation_levels(self):
621644
with get_new_node('node').init().start() as node:
622645
with node.connect() as con:

0 commit comments

Comments
 (0)