diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-04-02 10:03:46 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-04-10 13:52:27 +0000 |
commit | ee387ef30827fc769b3bab0fed1638d02af322fe (patch) | |
tree | 72e6a33b06d1d8031587692ae088121e5fc8a852 /morphlib/stagingarea_tests.py | |
parent | 3ebe37b1db1637f351d5d4652b0b80be0403f373 (diff) | |
download | morph-ee387ef30827fc769b3bab0fed1638d02af322fe.tar.gz |
fixup: Finish removing hardlink cache
Diffstat (limited to 'morphlib/stagingarea_tests.py')
-rw-r--r-- | morphlib/stagingarea_tests.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/morphlib/stagingarea_tests.py b/morphlib/stagingarea_tests.py index ffdf5eaa..3d378573 100644 --- a/morphlib/stagingarea_tests.py +++ b/morphlib/stagingarea_tests.py @@ -46,6 +46,25 @@ class FakeArtifact(object): self.source = FakeSource() +class FakeArtifactCache(object): + + def __init__(self, tempdir): + self.tempdir = tempdir + + def create_chunk(self, chunkdir): + if not chunkdir: + chunkdir = os.path.join(self.tempdir, 'chunk') + if not os.path.exists(chunkdir): + os.mkdir(chunkdir) + with open(os.path.join(chunkdir, 'file.txt'), 'w'): + pass + + return chunkdir + + def get(self, artifact, directory=None): + return self.create_chunk(directory) + + class FakeApplication(object): def __init__(self, cachedir, tempdir): @@ -141,14 +160,14 @@ class StagingAreaTests(unittest.TestCase): def test_installs_artifact(self): artifact = FakeArtifact() - chunkdir = self.create_chunk() - self.sa.install_artifact(artifact, chunkdir) + artifact_cache = FakeArtifactCache(self.tempdir) + self.sa.install_artifact(artifact_cache, artifact) self.assertEqual(self.list_tree(self.staging), ['/', '/file.txt']) def test_removes_everything(self): artifact = FakeArtifact() - chunkdir = self.create_chunk() - self.sa.install_artifact(artifact, chunkdir) + artifact_cache = FakeArtifactCache(self.tempdir) + self.sa.install_artifact(artifact_cache, artifact) self.sa.remove() self.assertFalse(os.path.exists(self.staging)) |