mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
xfconf: fix existing empty array case (#11026)
* xfconf: fix existing empty array case * fix xfconf_info as well * add changelog frag
This commit is contained in:
parent
9a7a316e24
commit
b28ac655fc
4 changed files with 62 additions and 4 deletions
3
changelogs/fragments/11026-xfconf-empty-array.yml
Normal file
3
changelogs/fragments/11026-xfconf-empty-array.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- xfconf - fix handling of empty array properties (https://github.com/ansible-collections/community.general/pull/11026).
|
||||||
|
- xfconf_info - fix handling of empty array properties (https://github.com/ansible-collections/community.general/pull/11026).
|
||||||
|
|
@ -209,8 +209,11 @@ class XFConfProperty(StateModuleHelper):
|
||||||
result = out.rstrip()
|
result = out.rstrip()
|
||||||
if "Value is an array with" in result:
|
if "Value is an array with" in result:
|
||||||
result = result.split("\n")
|
result = result.split("\n")
|
||||||
result.pop(0)
|
if len(result) > 1:
|
||||||
result.pop(0)
|
result.pop(0)
|
||||||
|
result.pop(0)
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,12 @@ class XFConfInfo(ModuleHelper):
|
||||||
result = out.rstrip()
|
result = out.rstrip()
|
||||||
if "Value is an array with" in result:
|
if "Value is an array with" in result:
|
||||||
result = result.split("\n")
|
result = result.split("\n")
|
||||||
result.pop(0)
|
|
||||||
result.pop(0)
|
|
||||||
self.vars.is_array = True
|
self.vars.is_array = True
|
||||||
|
if len(result) > 1:
|
||||||
|
result.pop(0)
|
||||||
|
result.pop(0)
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,55 @@ test_cases:
|
||||||
rc: 0
|
rc: 0
|
||||||
out: ''
|
out: ''
|
||||||
err: ''
|
err: ''
|
||||||
|
- id: test_property_array_previously_empty
|
||||||
|
input:
|
||||||
|
channel: xfwm4
|
||||||
|
property: /general/workspace_names
|
||||||
|
state: present
|
||||||
|
value_type: string
|
||||||
|
value: [A, B, C]
|
||||||
|
output:
|
||||||
|
changed: true
|
||||||
|
previous_value: []
|
||||||
|
type: [string, string, string]
|
||||||
|
value: [A, B, C]
|
||||||
|
version: 4.18.1
|
||||||
|
mocks:
|
||||||
|
run_command:
|
||||||
|
- command: [/testbin/xfconf-query, --version]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: *version-output
|
||||||
|
err: ''
|
||||||
|
- command: [/testbin/xfconf-query, --channel, xfwm4, --property, /general/workspace_names]
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: "Value is an array with 0 items:\n\n"
|
||||||
|
err: ''
|
||||||
|
- command:
|
||||||
|
- /testbin/xfconf-query
|
||||||
|
- --channel
|
||||||
|
- xfwm4
|
||||||
|
- --property
|
||||||
|
- /general/workspace_names
|
||||||
|
- --create
|
||||||
|
- --force-array
|
||||||
|
- --type
|
||||||
|
- string
|
||||||
|
- --set
|
||||||
|
- A
|
||||||
|
- --type
|
||||||
|
- string
|
||||||
|
- --set
|
||||||
|
- B
|
||||||
|
- --type
|
||||||
|
- string
|
||||||
|
- --set
|
||||||
|
- C
|
||||||
|
environ: *env-def
|
||||||
|
rc: 0
|
||||||
|
out: ''
|
||||||
|
err: ''
|
||||||
- id: test_property_reset_value
|
- id: test_property_reset_value
|
||||||
input:
|
input:
|
||||||
channel: xfwm4
|
channel: xfwm4
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue