mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge pull request #47939 from steveno/make_postgres_version_compare_more_robust
Make postgres version compare more robust
This commit is contained in:
commit
e456f84d95
@ -1465,10 +1465,10 @@ def is_available_extension(name,
|
|||||||
|
|
||||||
def _pg_is_older_ext_ver(a, b):
|
def _pg_is_older_ext_ver(a, b):
|
||||||
'''Return true if version a is lesser than b
|
'''Return true if version a is lesser than b
|
||||||
TODO: be more intelligent to test versions
|
|
||||||
|
|
||||||
|
Compare versions of extensions using salt.utils.versions.LooseVersion
|
||||||
'''
|
'''
|
||||||
return a < b
|
return _LooseVersion(a) < _LooseVersion(b)
|
||||||
|
|
||||||
|
|
||||||
def is_installed_extension(name,
|
def is_installed_extension(name,
|
||||||
|
@ -1479,3 +1479,22 @@ class PostgresTestCase(TestCase, LoaderModuleMockMixin):
|
|||||||
name = '/var/lib/pgsql/data'
|
name = '/var/lib/pgsql/data'
|
||||||
ret = postgres.datadir_exists(name)
|
ret = postgres.datadir_exists(name)
|
||||||
self.assertTrue(ret)
|
self.assertTrue(ret)
|
||||||
|
|
||||||
|
def test_pg_is_older_ext_ver(self):
|
||||||
|
'''
|
||||||
|
Test Checks if postgres extension version string is older
|
||||||
|
'''
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('8.5', '9.5'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('8.5', '8.6'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('8.5.2', '8.5.3'))
|
||||||
|
self.assertFalse(postgres._pg_is_older_ext_ver('9.5', '8.5'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('9.5', '9.6'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('9.5.0', '9.5.1'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('9.5', '9.5.1'))
|
||||||
|
self.assertFalse(postgres._pg_is_older_ext_ver('9.5.1', '9.5'))
|
||||||
|
self.assertFalse(postgres._pg_is_older_ext_ver('9.5b', '9.5a'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('10a', '10b'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('1.2.3.4', '1.2.3.5'))
|
||||||
|
self.assertTrue(postgres._pg_is_older_ext_ver('10dev', '10next'))
|
||||||
|
self.assertFalse(postgres._pg_is_older_ext_ver('10next', '10dev'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user