Skip to content

Commit

Permalink
gio_mime: fix bug when looking for version (#9171)
Browse files Browse the repository at this point in the history
* gio_mime: fix bug when looking for version

* add changelog frag
  • Loading branch information
russoz authored Nov 23, 2024
1 parent 47637cd commit 152339a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/9171-gio-mime-fix-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- gio_mime - fix command line when determining version of ``gio`` (https://github.com/ansible-collections/community.general/pull/9171, https://github.com/ansible-collections/community.general/issues/9158).
5 changes: 3 additions & 2 deletions plugins/module_utils/gio_mime.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
def gio_mime_runner(module, **kwargs):
return CmdRunner(
module,
command=['gio', 'mime'],
command=['gio'],
arg_formats=dict(
mime=cmd_runner_fmt.as_fixed('mime'),
mime_type=cmd_runner_fmt.as_list(),
handler=cmd_runner_fmt.as_list(),
version=cmd_runner_fmt.as_fixed('--version'),
Expand All @@ -29,5 +30,5 @@ def process(rc, out, err):
out = out.splitlines()[0]
return out.split()[-1]

with runner("mime_type", output_process=process) as ctx:
with runner("mime mime_type", output_process=process) as ctx:
return ctx.run(mime_type=mime_type)
5 changes: 2 additions & 3 deletions plugins/modules/gio_mime.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ def __init_module__(self):
def __run__(self):
check_mode_return = (0, 'Module executed in check mode', '')
if self.vars.has_changed:
with self.runner.context(args_order=["mime_type", "handler"], check_mode_skip=True, check_mode_return=check_mode_return) as ctx:
with self.runner.context(args_order="mime mime_type handler", check_mode_skip=True, check_mode_return=check_mode_return) as ctx:
rc, out, err = ctx.run()
self.vars.stdout = out
self.vars.stderr = err
if self.verbosity >= 4:
self.vars.run_info = ctx.run_info
self.vars.set("run_info", ctx.run_info, verbosity=4)


def main():
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/plugins/modules/test_gio_mime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
changed: true
mocks:
run_command:
- command: [/testbin/gio, mime, --version]
- command: [/testbin/gio, --version]
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
rc: 0
out: "2.80.0\n"
Expand All @@ -40,7 +40,7 @@
skip: test helper does not support check mode yet
mocks:
run_command:
- command: [/testbin/gio, mime, --version]
- command: [/testbin/gio, --version]
environ: *env-def
rc: 0
out: "2.80.0\n"
Expand All @@ -65,7 +65,7 @@
changed: false
mocks:
run_command:
- command: [/testbin/gio, mime, --version]
- command: [/testbin/gio, --version]
environ: *env-def
rc: 0
out: "2.80.0\n"
Expand Down

0 comments on commit 152339a

Please sign in to comment.