1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00

tests: make init apksigner test use existing test keystore

This test does not need to generate a keystore, so using the existing one
reduces the run time from 4 seconds to 0.040 seconds.  Also, if makes this
mystery error on macOS go away:

```
Traceback (most recent call last):
  File "/Users/travis/build/fdroidtravis/fdroidserver/tests/init.TestCase", line 66, in test_main_in_empty_dir
    fdroidserver.init.main()
  File "/Users/travis/build/fdroidtravis/fdroidserver/fdroidserver/init.py", line 231, in main
    common.genkeystore(c)
  File "/Users/travis/build/fdroidtravis/fdroidserver/fdroidserver/common.py", line 3434, in genkeystore
    cmd = [config['keytool'], '-genkey',
KeyError: 'keytool'

```
This commit is contained in:
Hans-Christoph Steiner 2021-01-29 09:04:48 +01:00
parent 5edb5d354a
commit 5cd9a8e396
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA

View File

@ -6,6 +6,7 @@ import inspect
import logging
import os
import optparse
import shutil
import sys
import tempfile
import unittest
@ -52,9 +53,12 @@ class InitTest(unittest.TestCase):
self.assertIsNone(config.get('keypass'))
def test_main_in_empty_dir(self):
"""Test that `fdroid init` will find apksigner and add it to the config"""
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)
os.chdir(testdir)
shutil.copy(os.path.join(self.basedir, 'keystore.jks'), testdir)
bindir = os.path.join(os.getcwd(), 'bin')
os.mkdir(bindir)
apksigner = os.path.join(bindir, 'apksigner')
@ -62,7 +66,7 @@ class InitTest(unittest.TestCase):
os.chmod(apksigner, 0o755)
os.environ['PATH'] = bindir
sys.argv = ['fdroid init']
sys.argv = ['fdroid init', '--keystore', 'keystore.jks', '--repo-keyalias=sova']
fdroidserver.init.main()
with open('config.yml') as fp:
config = yaml.safe_load(fp)