mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
add first test of addon files
This commit is contained in:
@@ -402,6 +402,15 @@ class BaseTest(object):
|
||||
else:
|
||||
raise
|
||||
|
||||
def write_file(self, path, content):
|
||||
full_path = os.path.join(os.environ["HOME"], ".aptly", path)
|
||||
|
||||
if not os.path.exists(os.path.dirname(full_path)):
|
||||
os.makedirs(os.path.dirname(full_path), 0o755)
|
||||
|
||||
with open(full_path, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
def read_file(self, path, mode=''):
|
||||
with open(os.path.join(os.environ["HOME"], self.aptlyDir, path), "r" + mode) as f:
|
||||
return f.read()
|
||||
|
||||
14
system/t06_publish/PublishRepo34Test_gold
Normal file
14
system/t06_publish/PublishRepo34Test_gold
Normal file
@@ -0,0 +1,14 @@
|
||||
Loading packages...
|
||||
Generating metadata files and linking package files...
|
||||
Finalizing metadata files...
|
||||
Signing file 'Release' with gpg, please enter your passphrase when prompted:
|
||||
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
|
||||
|
||||
Local repo local-repo has been successfully published.
|
||||
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
|
||||
Now you can add following line to apt sources:
|
||||
deb http://your-server/ maverick main
|
||||
deb-src http://your-server/ maverick main
|
||||
Don't forget to add your GPG key to apt with apt-key.
|
||||
|
||||
You can also use `aptly serve` to publish your repositories over HTTP quickly.
|
||||
@@ -888,3 +888,61 @@ class PublishRepo33Test(BaseTest):
|
||||
self.check_exists('public/dists/maverick/main/binary-amd64/Packages')
|
||||
self.check_exists('public/dists/maverick/main/binary-amd64/Packages.gz')
|
||||
self.check_not_exists('public/dists/maverick/main/binary-amd64/Packages.bz2')
|
||||
|
||||
|
||||
class PublishRepo34Test(BaseTest):
|
||||
"""
|
||||
publish repo: addon files
|
||||
"""
|
||||
fixtureCmds = [
|
||||
"aptly repo create local-repo",
|
||||
"aptly repo add local-repo ${files}"
|
||||
]
|
||||
runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -skip-contents local-repo"
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def prepare_fixture(self):
|
||||
super(PublishRepo34Test, self).prepare_fixture()
|
||||
|
||||
self.write_file(os.path.join('addon', 'dists', 'maverick', 'main', 'dep11', 'README'), 'README test file')
|
||||
|
||||
def check(self):
|
||||
super(PublishRepo34Test, self).check()
|
||||
|
||||
self.check_exists('public/dists/maverick/main/dep11/README')
|
||||
|
||||
self.check_exists('public/dists/maverick/Release')
|
||||
|
||||
readme = self.read_file('public/dists/maverick/main/dep11/README')
|
||||
if readme != 'README test file':
|
||||
raise Exception("README file not copied on publish")
|
||||
|
||||
release = self.read_file('public/dists/maverick/Release').split("\n")
|
||||
release = [l for l in release if l.startswith(" ")]
|
||||
pathsSeen = set()
|
||||
for l in release:
|
||||
fileHash, fileSize, path = l.split()
|
||||
pathsSeen.add(path)
|
||||
|
||||
fileSize = int(fileSize)
|
||||
|
||||
st = os.stat(os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/', path))
|
||||
if fileSize != st.st_size:
|
||||
raise Exception("file size doesn't match for %s: %d != %d" % (path, fileSize, st.st_size))
|
||||
|
||||
if len(fileHash) == 32:
|
||||
h = hashlib.md5()
|
||||
elif len(fileHash) == 40:
|
||||
h = hashlib.sha1()
|
||||
elif len(fileHash) == 64:
|
||||
h = hashlib.sha256()
|
||||
else:
|
||||
h = hashlib.sha512()
|
||||
|
||||
h.update(self.read_file(os.path.join('public/dists/maverick', path), mode='b'))
|
||||
|
||||
if h.hexdigest() != fileHash:
|
||||
raise Exception("file hash doesn't match for %s: %s != %s" % (path, fileHash, h.hexdigest()))
|
||||
|
||||
if 'main/dep11/README' not in pathsSeen:
|
||||
raise Exception("README file not included in release file")
|
||||
|
||||
Reference in New Issue
Block a user