From b163f23a2236e6253f6d55e9bffc1b3369526804 Mon Sep 17 00:00:00 2001 From: Aleksandr Mangin Date: Mon, 23 Sep 2019 18:35:44 +0200 Subject: [PATCH] fix tail message problem in get_log_events --- moto/logs/models.py | 2 ++ tests/test_logs/test_logs.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/moto/logs/models.py b/moto/logs/models.py index 2fc4b0d8b..3c5360371 100644 --- a/moto/logs/models.py +++ b/moto/logs/models.py @@ -115,6 +115,8 @@ class LogStream: events_page = [event.to_response_dict() for event in events[next_index: next_index + limit]] if next_index + limit < len(self.events): next_index += limit + else: + next_index = len(self.events) back_index -= limit if back_index <= 0: diff --git a/tests/test_logs/test_logs.py b/tests/test_logs/test_logs.py index 49e593fdc..0a63308c2 100644 --- a/tests/test_logs/test_logs.py +++ b/tests/test_logs/test_logs.py @@ -190,6 +190,8 @@ def test_get_log_events(): resp['events'].should.have.length_of(10) resp.should.have.key('nextForwardToken') resp.should.have.key('nextBackwardToken') + resp['nextForwardToken'].should.equal('f/00000000000000000000000000000000000000000000000000000010') + resp['nextBackwardToken'].should.equal('b/00000000000000000000000000000000000000000000000000000000') for i in range(10): resp['events'][i]['timestamp'].should.equal(i) resp['events'][i]['message'].should.equal(str(i)) @@ -205,7 +207,8 @@ def test_get_log_events(): resp['events'].should.have.length_of(10) resp.should.have.key('nextForwardToken') resp.should.have.key('nextBackwardToken') - resp['nextForwardToken'].should.equal(next_token) + resp['nextForwardToken'].should.equal('f/00000000000000000000000000000000000000000000000000000020') + resp['nextBackwardToken'].should.equal('b/00000000000000000000000000000000000000000000000000000000') for i in range(10): resp['events'][i]['timestamp'].should.equal(i+10) resp['events'][i]['message'].should.equal(str(i+10))