mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-10 04:30:32 -07: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>
(cherry picked from commit 8ef77d8664
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
231 lines
4.6 KiB
YAML
231 lines
4.6 KiB
YAML
# -*- coding: utf-8 -*-
|
|
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
---
|
|
- id: puppet_agent_plain
|
|
input: {}
|
|
output:
|
|
changed: false
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
|
rc: 0
|
|
out: "blah, anything"
|
|
err: ""
|
|
- command:
|
|
- /testbin/timeout
|
|
- -s
|
|
- "9"
|
|
- 30m
|
|
- /testbin/puppet
|
|
- agent
|
|
- --onetime
|
|
- --no-daemonize
|
|
- --no-usecacheonfailure
|
|
- --no-splay
|
|
- --detailed-exitcodes
|
|
- --verbose
|
|
- --color
|
|
- "0"
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- id: puppet_agent_certname
|
|
input:
|
|
certname: potatobox
|
|
output:
|
|
changed: false
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "blah, anything"
|
|
err: ""
|
|
- command:
|
|
- /testbin/timeout
|
|
- -s
|
|
- "9"
|
|
- 30m
|
|
- /testbin/puppet
|
|
- agent
|
|
- --onetime
|
|
- --no-daemonize
|
|
- --no-usecacheonfailure
|
|
- --no-splay
|
|
- --detailed-exitcodes
|
|
- --verbose
|
|
- --color
|
|
- "0"
|
|
- --certname=potatobox
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- id: puppet_agent_tags_abc
|
|
input:
|
|
tags: [a, b, c]
|
|
output:
|
|
changed: false
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "blah, anything"
|
|
err: ""
|
|
- command:
|
|
- /testbin/timeout
|
|
- -s
|
|
- "9"
|
|
- 30m
|
|
- /testbin/puppet
|
|
- agent
|
|
- --onetime
|
|
- --no-daemonize
|
|
- --no-usecacheonfailure
|
|
- --no-splay
|
|
- --detailed-exitcodes
|
|
- --verbose
|
|
- --color
|
|
- "0"
|
|
- --tags
|
|
- a,b,c
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- id: puppet_agent_skip_tags_def
|
|
input:
|
|
skip_tags: [d, e, f]
|
|
output:
|
|
changed: false
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "blah, anything"
|
|
err: ""
|
|
- command:
|
|
- /testbin/timeout
|
|
- -s
|
|
- "9"
|
|
- 30m
|
|
- /testbin/puppet
|
|
- agent
|
|
- --onetime
|
|
- --no-daemonize
|
|
- --no-usecacheonfailure
|
|
- --no-splay
|
|
- --detailed-exitcodes
|
|
- --verbose
|
|
- --color
|
|
- "0"
|
|
- --skip_tags
|
|
- d,e,f
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- id: puppet_agent_noop_false
|
|
input:
|
|
noop: false
|
|
output:
|
|
changed: false
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "blah, anything"
|
|
err: ""
|
|
- command:
|
|
- /testbin/timeout
|
|
- -s
|
|
- "9"
|
|
- 30m
|
|
- /testbin/puppet
|
|
- agent
|
|
- --onetime
|
|
- --no-daemonize
|
|
- --no-usecacheonfailure
|
|
- --no-splay
|
|
- --detailed-exitcodes
|
|
- --verbose
|
|
- --color
|
|
- "0"
|
|
- --no-noop
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- id: puppet_agent_noop_true
|
|
input:
|
|
noop: true
|
|
output:
|
|
changed: false
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "blah, anything"
|
|
err: ""
|
|
- command:
|
|
- /testbin/timeout
|
|
- -s
|
|
- "9"
|
|
- 30m
|
|
- /testbin/puppet
|
|
- agent
|
|
- --onetime
|
|
- --no-daemonize
|
|
- --no-usecacheonfailure
|
|
- --no-splay
|
|
- --detailed-exitcodes
|
|
- --verbose
|
|
- --color
|
|
- "0"
|
|
- --noop
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|
|
- id: puppet_agent_waitforlock
|
|
input:
|
|
waitforlock: 30
|
|
output:
|
|
changed: false
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/puppet, config, print, agent_disabled_lockfile]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "blah, anything"
|
|
err: ""
|
|
- command:
|
|
- /testbin/timeout
|
|
- -s
|
|
- "9"
|
|
- 30m
|
|
- /testbin/puppet
|
|
- agent
|
|
- --onetime
|
|
- --no-daemonize
|
|
- --no-usecacheonfailure
|
|
- --no-splay
|
|
- --detailed-exitcodes
|
|
- --verbose
|
|
- --color
|
|
- "0"
|
|
- --waitforlock
|
|
- "30"
|
|
environ: *env-def
|
|
rc: 0
|
|
out: ""
|
|
err: ""
|