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

Merge branch 'test_version_update' into 'master'

[checkupdates] Only update if version code is grater

See merge request fdroid/fdroidserver!963
This commit is contained in:
Jochen Sprickerhof 2021-06-17 11:52:48 +00:00
commit f44bd8d928
2 changed files with 15 additions and 1 deletions

View File

@ -511,12 +511,16 @@ def checkupdates_app(app):
logging.warning(logmsg) logging.warning(logmsg)
elif vercode == app.CurrentVersionCode: elif vercode == app.CurrentVersionCode:
logging.info("...up to date") logging.info("...up to date")
else: elif int(vercode) > int(app.CurrentVersionCode):
logging.debug("...updating - old vercode={0}, new vercode={1}".format( logging.debug("...updating - old vercode={0}, new vercode={1}".format(
app.CurrentVersionCode, vercode)) app.CurrentVersionCode, vercode))
app.CurrentVersion = version app.CurrentVersion = version
app.CurrentVersionCode = str(int(vercode)) app.CurrentVersionCode = str(int(vercode))
updating = True updating = True
else:
logging.info("Refusing to auto update, since the current version is newer")
logging.debug("...old vercode={0}, new vercode={1}".format(
app.CurrentVersionCode, vercode))
commitmsg = fetch_autoname(app, tag) commitmsg = fetch_autoname(app, tag)

View File

@ -60,6 +60,16 @@ class CheckupdatesTest(unittest.TestCase):
self.assertEqual(build.versionName, '1.1.9') self.assertEqual(build.versionName, '1.1.9')
self.assertEqual(build.commit, '1.1.9') self.assertEqual(build.commit, '1.1.9')
with mock.patch(
'fdroidserver.checkupdates.check_http', lambda app: ('1.7.9', 10107)
):
with mock.patch('fdroidserver.metadata.write_metadata', mock.Mock()):
with mock.patch('subprocess.call', lambda cmd: 0):
fdroidserver.checkupdates.checkupdates_app(app)
build = app['Builds'][-1]
self.assertEqual(build.versionName, '1.1.9')
self.assertEqual(build.commit, '1.1.9')
def test_autoupdatemode_suffix(self): def test_autoupdatemode_suffix(self):
fdroidserver.checkupdates.options = mock.Mock() fdroidserver.checkupdates.options = mock.Mock()
fdroidserver.checkupdates.options.auto = 'bleh' fdroidserver.checkupdates.options.auto = 'bleh'