diff options
Diffstat (limited to 'tests/test_repo_trace.py')
| -rw-r--r-- | tests/test_repo_trace.py | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/tests/test_repo_trace.py b/tests/test_repo_trace.py index 5faf2938..e4aeb5de 100644 --- a/tests/test_repo_trace.py +++ b/tests/test_repo_trace.py | |||
| @@ -22,35 +22,39 @@ import repo_trace | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | class TraceTests(unittest.TestCase): | 24 | class TraceTests(unittest.TestCase): |
| 25 | """Check Trace behavior.""" | 25 | """Check Trace behavior.""" |
| 26 | 26 | ||
| 27 | def testTrace_MaxSizeEnforced(self): | 27 | def testTrace_MaxSizeEnforced(self): |
| 28 | content = 'git chicken' | 28 | content = "git chicken" |
| 29 | 29 | ||
| 30 | with repo_trace.Trace(content, first_trace=True): | 30 | with repo_trace.Trace(content, first_trace=True): |
| 31 | pass | 31 | pass |
| 32 | first_trace_size = os.path.getsize(repo_trace._TRACE_FILE) | 32 | first_trace_size = os.path.getsize(repo_trace._TRACE_FILE) |
| 33 | 33 | ||
| 34 | with repo_trace.Trace(content): | 34 | with repo_trace.Trace(content): |
| 35 | pass | 35 | pass |
| 36 | self.assertGreater( | 36 | self.assertGreater( |
| 37 | os.path.getsize(repo_trace._TRACE_FILE), first_trace_size) | 37 | os.path.getsize(repo_trace._TRACE_FILE), first_trace_size |
| 38 | 38 | ) | |
| 39 | # Check we clear everything is the last chunk is larger than _MAX_SIZE. | 39 | |
| 40 | with mock.patch('repo_trace._MAX_SIZE', 0): | 40 | # Check we clear everything is the last chunk is larger than _MAX_SIZE. |
| 41 | with repo_trace.Trace(content, first_trace=True): | 41 | with mock.patch("repo_trace._MAX_SIZE", 0): |
| 42 | pass | 42 | with repo_trace.Trace(content, first_trace=True): |
| 43 | self.assertEqual(first_trace_size, | 43 | pass |
| 44 | os.path.getsize(repo_trace._TRACE_FILE)) | 44 | self.assertEqual( |
| 45 | 45 | first_trace_size, os.path.getsize(repo_trace._TRACE_FILE) | |
| 46 | # Check we only clear the chunks we need to. | 46 | ) |
| 47 | repo_trace._MAX_SIZE = (first_trace_size + 1) / (1024 * 1024) | 47 | |
| 48 | with repo_trace.Trace(content, first_trace=True): | 48 | # Check we only clear the chunks we need to. |
| 49 | pass | 49 | repo_trace._MAX_SIZE = (first_trace_size + 1) / (1024 * 1024) |
| 50 | self.assertEqual(first_trace_size * 2, | 50 | with repo_trace.Trace(content, first_trace=True): |
| 51 | os.path.getsize(repo_trace._TRACE_FILE)) | 51 | pass |
| 52 | 52 | self.assertEqual( | |
| 53 | with repo_trace.Trace(content, first_trace=True): | 53 | first_trace_size * 2, os.path.getsize(repo_trace._TRACE_FILE) |
| 54 | pass | 54 | ) |
| 55 | self.assertEqual(first_trace_size * 2, | 55 | |
| 56 | os.path.getsize(repo_trace._TRACE_FILE)) | 56 | with repo_trace.Trace(content, first_trace=True): |
| 57 | pass | ||
| 58 | self.assertEqual( | ||
| 59 | first_trace_size * 2, os.path.getsize(repo_trace._TRACE_FILE) | ||
| 60 | ) | ||
