Skip to content

Commit

Permalink
DRY: using YAML anchors and aliases (ansible-collections#7248)
Browse files Browse the repository at this point in the history
  • Loading branch information
russoz authored and Eric Trombly committed Oct 25, 2023
1 parent 5698dc4 commit 15ed7f2
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 75 deletions.
30 changes: 15 additions & 15 deletions tests/unit/plugins/modules/test_cpanm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
changed: true
run_command_calls:
- command: [/testbin/perl, -le, 'use Dancer;']
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: &env-def-false {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
rc: 2
out: ""
err: "error, not installed"
- command: [/testbin/cpanm, Dancer]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: &env-def-true {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
rc: 0
out: ""
err: ""
Expand All @@ -27,7 +27,7 @@
changed: false
run_command_calls:
- command: [/testbin/perl, -le, 'use Dancer;']
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def-false
rc: 0
out: ""
err: ""
Expand All @@ -39,7 +39,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, Dancer]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -50,7 +50,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, MIYAGAWA/Plack-0.99_05.tar.gz]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -62,7 +62,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, MIYAGAWA/Plack-0.99_05.tar.gz]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -75,7 +75,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, --local-lib, /srv/webapps/my_app/extlib, Dancer]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -87,7 +87,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, /srv/webapps/my_app/src/]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -101,7 +101,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, --notest, --local-lib, /srv/webapps/my_app/extlib, Dancer]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -114,7 +114,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, --mirror, "http://cpan.cpantesters.org/", Dancer]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -135,7 +135,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, Dancer~1.0]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -148,7 +148,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, Dancer~1.5]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -161,7 +161,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, [email protected]]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand Down Expand Up @@ -192,7 +192,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, "git://github.com/plack/[email protected]"]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand All @@ -205,7 +205,7 @@
changed: true
run_command_calls:
- command: [/testbin/cpanm, "git://github.com/plack/[email protected]"]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def-true
rc: 0
out: ""
err: ""
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/plugins/modules/test_gconftool2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
output: {}
run_command_calls:
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
rc: 0
out: "100\n"
err: ""
Expand All @@ -22,7 +22,7 @@
output: {}
run_command_calls:
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: "No value set for `/desktop/gnome/background/picture_filename'\n"
Expand All @@ -37,17 +37,17 @@
changed: true
run_command_calls:
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: "100\n"
err: ""
- command: [/testbin/gconftool-2, --type, int, --set, /desktop/gnome/background/picture_filename, "200"]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: "200\n"
err: ""
Expand All @@ -62,17 +62,17 @@
changed: false
run_command_calls:
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: "200\n"
err: ""
- command: [/testbin/gconftool-2, --type, int, --set, /desktop/gnome/background/picture_filename, "200"]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: "200\n"
err: ""
Expand All @@ -87,17 +87,17 @@
changed: false
run_command_calls:
- command: [/testbin/gconftool-2, --get, /apps/gnome_settings_daemon/screensaver/start_screensaver]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: "false\n"
err: ""
- command: [/testbin/gconftool-2, --type, bool, --set, /apps/gnome_settings_daemon/screensaver/start_screensaver, "False"]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/gconftool-2, --get, /apps/gnome_settings_daemon/screensaver/start_screensaver]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: "false\n"
err: ""
Expand All @@ -110,12 +110,12 @@
changed: true
run_command_calls:
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: "200\n"
err: ""
- command: [/testbin/gconftool-2, --unset, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: ""
Expand All @@ -128,12 +128,12 @@
changed: false
run_command_calls:
- command: [/testbin/gconftool-2, --get, /apps/gnome_settings_daemon/screensaver/start_screensaver]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/gconftool-2, --unset, /apps/gnome_settings_daemon/screensaver/start_screensaver]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: ""
4 changes: 2 additions & 2 deletions tests/unit/plugins/modules/test_gconftool2_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
value: '100'
run_command_calls:
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
rc: 0
out: "100\n"
err: ""
Expand All @@ -22,7 +22,7 @@
value: null
run_command_calls:
- command: [/testbin/gconftool-2, --get, /desktop/gnome/background/picture_filename]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
environ: *env-def
rc: 0
out: ""
err: "No value set for `/desktop/gnome/background/picture_filename'\n"
28 changes: 14 additions & 14 deletions tests/unit/plugins/modules/test_opkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
msg: installed 1 package(s)
run_command_calls:
- command: [/testbin/opkg, list-installed, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
rc: 0
out: ""
err: ""
- command: [/testbin/opkg, install, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
Installing zlib-dev (1.2.11-6) to root...
Expand All @@ -28,7 +28,7 @@
Configuring zlib-dev.
err: ""
- command: [/testbin/opkg, list-installed, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
zlib-dev - 1.2.11-6
Expand All @@ -41,7 +41,7 @@
msg: package(s) already present
run_command_calls:
- command: [/testbin/opkg, list-installed, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
zlib-dev - 1.2.11-6
Expand All @@ -55,21 +55,21 @@
msg: installed 1 package(s)
run_command_calls:
- command: [/testbin/opkg, list-installed, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
zlib-dev - 1.2.11-6
err: ""
- command: [/testbin/opkg, install, --force-reinstall, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
Installing zlib-dev (1.2.11-6) to root...
Downloading https://downloads.openwrt.org/releases/22.03.0/packages/mips_24kc/base/zlib-dev_1.2.11-6_mips_24kc.ipk
Configuring zlib-dev.
err: ""
- command: [/testbin/opkg, list-installed, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
zlib-dev - 1.2.11-6
Expand All @@ -82,12 +82,12 @@
msg: installed 1 package(s)
run_command_calls:
- command: [/testbin/opkg, list-installed, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/opkg, install, zlib-dev=1.2.11-6]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
Installing zlib-dev (1.2.11-6) to root...
Expand All @@ -98,7 +98,7 @@
Configuring zlib-dev.
err: ""
- command: [/testbin/opkg, list-installed, zlib-dev]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: "zlib-dev - 1.2.11-6 \n" # This output has the extra space at the end, to satisfy the behaviour of Yocto/OpenEmbedded's opkg
err: ""
Expand All @@ -111,17 +111,17 @@
msg: installed 1 package(s)
run_command_calls:
- command: [/testbin/opkg, update]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/opkg, list-installed, vim-fuller]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/opkg, install, vim-fuller]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: |
Multiple packages (libgcc1 and libgcc1) providing same name marked HOLD or PREFER. Using latest.
Expand All @@ -136,7 +136,7 @@
Configuring vim-fuller.
err: ""
- command: [/testbin/opkg, list-installed, vim-fuller]
environ: {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
environ: *env-def
rc: 0
out: "vim-fuller - 9.0-1 \n" # This output has the extra space at the end, to satisfy the behaviour of Yocto/OpenEmbedded's opkg
err: ""
Loading

0 comments on commit 15ed7f2

Please sign in to comment.