mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
unit test helper: big revamp (#8894)
* initial commit * multiple changes: - TestCaseContext fixture no longer need to autouse=True - Helper.from_module() allows extra param to specify yaml file - test_django_check: adjusted .py and .yaml * set fixtures per testcase * set fixtures per testcase * rollback to original state * patch_ansible_module fixture - now it works not only in parametrized functions but also directly with args * tests/unit/plugins/modules/helper.py - improved encapsulation, class Helper no longer knows details about test cases - test functions no longer parametrized, that allows using test case fixtures per test function - renamed 'context' to 'mock' * enable Helper.from_list(), better param name 'ansible_module' * adjusted test fiels to new helper * remove unnecessary .license file * fix bracket * fix reference name * Update tests/unit/plugins/modules/helper.py Co-authored-by: Felix Fontein <felix@fontein.de> * revert to parametrized test func instead of multiple funcs --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
mode: compatibility
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/perl, -le, 'use Dancer;']
|
||||
environ: &env-def-false {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
||||
rc: 2
|
||||
@@ -27,7 +28,8 @@
|
||||
mode: compatibility
|
||||
output:
|
||||
changed: false
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/perl, -le, 'use Dancer;']
|
||||
environ: *env-def-false
|
||||
rc: 0
|
||||
@@ -38,7 +40,8 @@
|
||||
name: Dancer
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, Dancer]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -50,7 +53,8 @@
|
||||
mode: compatibility
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, MIYAGAWA/Plack-0.99_05.tar.gz]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -61,7 +65,8 @@
|
||||
name: MIYAGAWA/Plack-0.99_05.tar.gz
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, MIYAGAWA/Plack-0.99_05.tar.gz]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -74,7 +79,8 @@
|
||||
locallib: /srv/webapps/my_app/extlib
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, --local-lib, /srv/webapps/my_app/extlib, Dancer]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -86,7 +92,8 @@
|
||||
mode: new
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, /srv/webapps/my_app/src/]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -100,7 +107,8 @@
|
||||
locallib: /srv/webapps/my_app/extlib
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, --notest, --local-lib, /srv/webapps/my_app/extlib, Dancer]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -113,7 +121,8 @@
|
||||
mirror: "http://cpan.cpantesters.org/"
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, --mirror, "http://cpan.cpantesters.org/", Dancer]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -126,7 +135,8 @@
|
||||
system_lib: true
|
||||
output:
|
||||
failed: true
|
||||
run_command_calls: []
|
||||
mocks:
|
||||
run_command: []
|
||||
- id: install_minversion_implicit
|
||||
input:
|
||||
name: Dancer
|
||||
@@ -134,7 +144,8 @@
|
||||
version: "1.0"
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, Dancer~1.0]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -147,7 +158,8 @@
|
||||
version: "~1.5"
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, Dancer~1.5]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -160,7 +172,8 @@
|
||||
version: "@1.7"
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, Dancer@1.7]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -174,7 +187,8 @@
|
||||
output:
|
||||
failed: true
|
||||
msg: parameter 'version' must not be used when installing from a file
|
||||
run_command_calls: []
|
||||
mocks:
|
||||
run_command: []
|
||||
- id: install_specific_version_from_directory_error
|
||||
input:
|
||||
from_path: ~/
|
||||
@@ -183,7 +197,8 @@
|
||||
output:
|
||||
failed: true
|
||||
msg: parameter 'version' must not be used when installing from a directory
|
||||
run_command_calls: []
|
||||
mocks:
|
||||
run_command: []
|
||||
- id: install_specific_version_from_git_url_explicit
|
||||
input:
|
||||
name: "git://github.com/plack/Plack.git"
|
||||
@@ -191,7 +206,8 @@
|
||||
version: "@1.7"
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, "git://github.com/plack/Plack.git@1.7"]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -204,7 +220,8 @@
|
||||
version: "2.5"
|
||||
output:
|
||||
changed: true
|
||||
run_command_calls:
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/cpanm, "git://github.com/plack/Plack.git@2.5"]
|
||||
environ: *env-def-true
|
||||
rc: 0
|
||||
@@ -218,4 +235,5 @@
|
||||
output:
|
||||
failed: true
|
||||
msg: operator '~' not allowed in version parameter when installing from git repository
|
||||
run_command_calls: []
|
||||
mocks:
|
||||
run_command: []
|
||||
|
||||
Reference in New Issue
Block a user