diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2014-03-28 14:22:39 +0000 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2014-03-28 14:22:39 +0000 |
commit | 6d9eee86f1ea75c0f2666dc4282d8b10fee63e7b (patch) | |
tree | 657a6891ad531e8f71784847b42b3c2e625d7604 /morphlib/cachekeycomputer_tests.py | |
parent | 3efb9f405ae8f1dafcfbb7f06e009f0a6b054f10 (diff) | |
download | morph-6d9eee86f1ea75c0f2666dc4282d8b10fee63e7b.tar.gz |
CacheKeyComputer Tests: Update to explicitly test for memoisationbaserock/danielsilverstone/memoise-cache-keys-better
Explicitly test that we get the same result twice when computing
ids and keys for the same artifact.
This has the effect of verifying that the memoisation code is
correctly operating.
Signed-Off-By: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
Diffstat (limited to 'morphlib/cachekeycomputer_tests.py')
-rw-r--r-- | morphlib/cachekeycomputer_tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 4e73e905..dd10307f 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -148,6 +148,19 @@ class CacheKeyComputerTests(unittest.TestCase): validchars = '0123456789abcdef' return len(s) == 64 and all([c in validchars for c in s]) + def test_compute_twice_same_key(self): + artifact = self._find_artifact('system-rootfs') + self.assertEqual(self.ckc.compute_key(artifact), + self.ckc.compute_key(artifact)) + + def test_compute_twice_same_id(self): + artifact = self._find_artifact('system-rootfs') + id1 = self.ckc.get_cache_id(artifact) + id2 = self.ckc.get_cache_id(artifact) + hash1 = self.ckc._hash_id(id1) + hash2 = self.ckc._hash_id(id2) + self.assertEqual(hash1, hash2) + def test_compute_key_returns_sha256(self): artifact = self._find_artifact('system-rootfs') self.assertTrue(self._valid_sha256( |