diff --git a/system/lib.py b/system/lib.py index b7fccd36..a1374b61 100644 --- a/system/lib.py +++ b/system/lib.py @@ -154,6 +154,7 @@ class BaseTest(object): if not hasattr(command, "__iter__"): params = { 'files': os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), + 'changes': os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), 'udebs': os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "udebs"), 'testfiles': os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), 'aptlyroot': os.path.join(os.environ["HOME"], ".aptly"), diff --git a/system/t09_repo/IncludeRepo1Test_gold b/system/t09_repo/IncludeRepo1Test_gold new file mode 100644 index 00000000..456eb0b5 --- /dev/null +++ b/system/t09_repo/IncludeRepo1Test_gold @@ -0,0 +1,5 @@ +gpgv: Signature made Sun Mar 15 20:36:44 2015 MSK using DSA key ID 16DB3E6D +gpgv: Good signature from "Aptly Tester (don't use it) " +Loading repository unstable for changes file hardlink_0.2.1_amd64.changes... +[+] hardlink_0.2.1_source added +[+] hardlink_0.2.1_amd64 added diff --git a/system/t09_repo/IncludeRepo1Test_repo_show b/system/t09_repo/IncludeRepo1Test_repo_show new file mode 100644 index 00000000..6543b523 --- /dev/null +++ b/system/t09_repo/IncludeRepo1Test_repo_show @@ -0,0 +1,8 @@ +Name: unstable +Comment: +Default Distribution: +Default Component: main +Number of packages: 2 +Packages: + hardlink_0.2.1_amd64 + hardlink_0.2.1_source diff --git a/system/t09_repo/IncludeRepo2Test_gold b/system/t09_repo/IncludeRepo2Test_gold new file mode 100644 index 00000000..a9f191f2 --- /dev/null +++ b/system/t09_repo/IncludeRepo2Test_gold @@ -0,0 +1,5 @@ +gpgv: DSA key ID 16DB3E6D +gpgv: Good signature from "Aptly Tester (don't use it) " +Loading repository my-unstable for changes file hardlink_0.2.1_amd64.changes... +[+] hardlink_0.2.1_source added +[+] hardlink_0.2.1_amd64 added diff --git a/system/t09_repo/IncludeRepo2Test_repo_show b/system/t09_repo/IncludeRepo2Test_repo_show new file mode 100644 index 00000000..ab2503c0 --- /dev/null +++ b/system/t09_repo/IncludeRepo2Test_repo_show @@ -0,0 +1,11 @@ +Name: my-unstable +Comment: +Default Distribution: +Default Component: main +Number of packages: 5 +Packages: + hardlink_0.2.1_amd64 + libboost-program-options-dev_1.49.0.1_i386 + hardlink_0.2.1_source + pyspi_0.6.1-1.3_source + pyspi_0.6.1-1.4_source diff --git a/system/t09_repo/IncludeRepo3Test_gold b/system/t09_repo/IncludeRepo3Test_gold new file mode 100644 index 00000000..96cda590 --- /dev/null +++ b/system/t09_repo/IncludeRepo3Test_gold @@ -0,0 +1 @@ +ERROR: error parsing -repo template: template: repo:1: unexpected "}" in operand; missing space? diff --git a/system/t09_repo/IncludeRepo4Test_gold b/system/t09_repo/IncludeRepo4Test_gold new file mode 100644 index 00000000..2fcf3fd4 --- /dev/null +++ b/system/t09_repo/IncludeRepo4Test_gold @@ -0,0 +1,5 @@ +Loading repository unstable for changes file hardlink_0.2.1_amd64.changes... +[!] unable to process file hardlink_0.2.1_amd64.changes: local repo with name unstable not found +[!] Some files were skipped due to errors: + /hardlink_0.2.1_amd64.changes +ERROR: some files failed to be added diff --git a/system/t09_repo/__init__.py b/system/t09_repo/__init__.py index 54b70ef5..302f65c1 100644 --- a/system/t09_repo/__init__.py +++ b/system/t09_repo/__init__.py @@ -14,3 +14,4 @@ from .remove import * from .show import * from .rename import * from .search import * +from .include import * diff --git a/system/t09_repo/include.py b/system/t09_repo/include.py new file mode 100644 index 00000000..b942ba73 --- /dev/null +++ b/system/t09_repo/include.py @@ -0,0 +1,71 @@ +import tempfile +import shutil +import os +import inspect +import re +from lib import BaseTest + +gpgRemove = lambda _, s: re.sub(r'Signature made .* using|gpgv: keyblock resource .*$|gpgv: Can\'t check signature: .*$', '', s, flags=re.MULTILINE) +changesRemove = lambda _, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), "") + + +class IncludeRepo1Test(BaseTest): + """ + incldue packages to local repo: .changes file from directory + """ + fixtureCmds = [ + "aptly repo create unstable", + ] + runCmd = "aptly repo include -no-remove-files -keyring=${files}/aptly.pub ${changes}" + outputMatchPrepare = gpgRemove + + def check(self): + self.check_output() + self.check_cmd_output("aptly repo show -with-packages unstable", "repo_show") + + # check pool + self.check_exists('pool//20/81/hardlink_0.2.1_amd64.deb') + self.check_exists('pool/4e/fc/hardlink_0.2.1.dsc') + self.check_exists('pool/8e/2c/hardlink_0.2.1.tar.gz') + + +class IncludeRepo2Test(BaseTest): + """ + incldue packages to local repo: .changes file from file + custom repo + """ + fixtureCmds = [ + "aptly repo create my-unstable", + "aptly repo add my-unstable ${files}", + ] + runCmd = "aptly repo include -no-remove-files -keyring=${files}/aptly.pub -repo=my-{{.Distribution}} ${changes}/hardlink_0.2.1_amd64.changes" + outputMatchPrepare = gpgRemove + + def check(self): + self.check_output() + self.check_cmd_output("aptly repo show -with-packages my-unstable", "repo_show") + + # check pool + self.check_exists('pool//20/81/hardlink_0.2.1_amd64.deb') + self.check_exists('pool/4e/fc/hardlink_0.2.1.dsc') + self.check_exists('pool/8e/2c/hardlink_0.2.1.tar.gz') + + +class IncludeRepo3Test(BaseTest): + """ + incldue packages to local repo: broken repo flag + """ + fixtureCmds = [ + ] + runCmd = "aptly repo include -no-remove-files -keyring=${files}/aptly.pub -repo=my-{{.Distribution} ${changes}" + expectedCode = 1 + + +class IncludeRepo4Test(BaseTest): + """ + incldue packages to local repo: missing repo + """ + fixtureCmds = [ + ] + runCmd = "aptly repo include -no-remove-files -ignore-signatures -keyring=${files}/aptly.pub ${changes}" + outputMatchPrepare = changesRemove + expectedCode = 1