From 951b6e900413018a38c32d781fb3fb557ee031a9 Mon Sep 17 00:00:00 2001 From: Simon Aquino Date: Thu, 16 Oct 2014 14:51:42 +0100 Subject: [PATCH] Test to avoid published file truncation when added to repo This test will make sure that when a published file is added to repo, it doesn't get truncated. --- system/lib.py | 4 ++++ system/t09_repo/add.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/system/lib.py b/system/lib.py index 2e328bdd..2f4ee6be 100644 --- a/system/lib.py +++ b/system/lib.py @@ -258,6 +258,10 @@ class BaseTest(object): if os.path.exists(os.path.join(os.environ["HOME"], ".aptly", path)): raise Exception("path %s exists" % (path, )) + def check_file_not_empty(self, path): + if os.stat(path)[6] == 0: + raise Exception("file %s is empty" % (path, )) + def check_equal(self, a, b): if a != b: self.verify_match(a, b, match_prepare=pprint.pformat) diff --git a/system/t09_repo/add.py b/system/t09_repo/add.py index 9b5d9319..21e30e7e 100644 --- a/system/t09_repo/add.py +++ b/system/t09_repo/add.py @@ -267,3 +267,19 @@ class AddRepo13Test(BaseTest): # check pool self.check_exists('pool/72/16/dmraid-udeb_1.0.0.rc16-4.1_amd64.udeb') self.check_exists('pool/b7/2c/pyspi_0.6.1-1.3.dsc') + +class AddRepo14Test(BaseTest): + """ + add same package to local repo twice and make sure the file doesn't get truncated. + """ + fixtureCmds = [ + "aptly repo create -comment=Repo1 -distribution=squeeze repo1", + ] + runCmd = "aptly repo add repo1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb; + aptly repo add repo1 pool/00/35/libboost-program-options-dev_1.49.0.1_i386.deb" + + def check(self): + # check pool + self.check_file_not_empty('pool/00/35/libboost-program-options-dev_1.49.0.1_i386.deb') + +