mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
postgresql_ext: fix module's failing when available ext versions contain a pure string (#1099)
* postgresql_ext: fix module's failing when available ext versions contain a pure string * Add unit tests * Add changelog fragment * fix
This commit is contained in:
parent
7f1e26167a
commit
398421a9d1
4 changed files with 85 additions and 6 deletions
|
@ -330,6 +330,23 @@
|
|||
- result.failed == true
|
||||
- result.msg == "Extension non_existent is not installed"
|
||||
|
||||
######################################################################
|
||||
# https://github.com/ansible-collections/community.general/issues/1095
|
||||
- name: Install postgis
|
||||
package:
|
||||
name: postgis
|
||||
|
||||
- name: Create postgis extension
|
||||
<<: *task_parameters
|
||||
postgresql_ext:
|
||||
<<: *pg_parameters
|
||||
name: postgis
|
||||
version: latest
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
# Cleanup:
|
||||
- name: postgresql_ext_version - drop the extension
|
||||
<<: *task_parameters
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# Copyright 2020, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible_collections.community.general.plugins.modules.database.postgresql.postgresql_ext import (
|
||||
parse_ext_versions,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'current,test_input,expected',
|
||||
[
|
||||
(
|
||||
'2.0.0',
|
||||
[{'version': '3.1.0dev'}, {'version': '3.1.0devnext'}, {'version': 'unpackaged'}],
|
||||
['3.1.0dev', '3.1.0devnext'],
|
||||
),
|
||||
(
|
||||
'2.0.0',
|
||||
[{'version': 'unpackaged'}, {'version': '3.1.0dev'}, {'version': '3.1.0devnext'}],
|
||||
['3.1.0dev', '3.1.0devnext'],
|
||||
),
|
||||
(
|
||||
'2.0.1',
|
||||
[{'version': 'unpackaged'}, {'version': '2.0.0'}, {'version': '2.1.0dev'}],
|
||||
['2.1.0dev'],
|
||||
),
|
||||
]
|
||||
)
|
||||
def test_parse_ext_versions(current, test_input, expected):
|
||||
assert parse_ext_versions(current, test_input) == expected
|
Loading…
Add table
Add a link
Reference in a new issue