mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-30 23:33:09 +00:00
gio_mime: add return value version (#9067)
* add return value version * add changelog frag
This commit is contained in:
3
changelogs/fragments/9067-gio-mime-version.yml
Normal file
3
changelogs/fragments/9067-gio-mime-version.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
minor_changes:
|
||||
- gio_mime module utils - add argument formatter ``version`` (https://github.com/ansible-collections/community.general/pull/9067).
|
||||
- gio_mime - add return value ``version`` (https://github.com/ansible-collections/community.general/pull/9067).
|
||||
@@ -16,6 +16,7 @@ def gio_mime_runner(module, **kwargs):
|
||||
arg_formats=dict(
|
||||
mime_type=cmd_runner_fmt.as_list(),
|
||||
handler=cmd_runner_fmt.as_list(),
|
||||
version=cmd_runner_fmt.as_fixed('--version'),
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@@ -75,6 +75,12 @@ stderr:
|
||||
returned: failure
|
||||
type: str
|
||||
sample: 'gio: Failed to load info for handler "never-existed.desktop"'
|
||||
version:
|
||||
description: Version of gio.
|
||||
type: str
|
||||
returned: always
|
||||
sample: "2.80.0"
|
||||
version_added: 10.0.0
|
||||
"""
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
||||
@@ -94,6 +100,9 @@ class GioMime(ModuleHelper):
|
||||
|
||||
def __init_module__(self):
|
||||
self.runner = gio_mime_runner(self.module, check_rc=True)
|
||||
with self.runner("version") as ctx:
|
||||
rc, out, err = ctx.run()
|
||||
self.vars.version = out.strip()
|
||||
self.vars.set_meta("handler", initial_value=gio_mime_get(self.runner, self.vars.mime_type), diff=True, change=True)
|
||||
|
||||
def __run__(self):
|
||||
|
||||
@@ -13,9 +13,14 @@
|
||||
changed: true
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||
- command: [/testbin/gio, mime, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
err: ""
|
||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: ""
|
||||
err: >
|
||||
No default applications for “x-scheme-handler/http”
|
||||
@@ -35,6 +40,11 @@
|
||||
skip: test helper does not support check mode yet
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gio, mime, --version]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
err: ""
|
||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
@@ -55,6 +65,11 @@
|
||||
changed: false
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gio, mime, --version]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
err: ""
|
||||
- command: [/testbin/gio, mime, x-scheme-handler/http]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
|
||||
Reference in New Issue
Block a user