mirror of https://github.com/ansible/ansible.git
Add initial ansible-test tests for collections. (#68533)
parent
735885d57c
commit
0fb5593abf
@ -0,0 +1,2 @@
|
|||||||
|
shippable/posix/group1
|
||||||
|
skip/aix
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
def hello(name):
|
||||||
|
return 'Hello %s' % name
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
module: hello
|
||||||
|
short_description: Hello test module
|
||||||
|
description: Hello test module.
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description: Name to say hello to.
|
||||||
|
type: str
|
||||||
|
author:
|
||||||
|
- Ansible Core Team
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = '''
|
||||||
|
- minimal:
|
||||||
|
'''
|
||||||
|
|
||||||
|
RETURN = ''''''
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ..module_utils.my_util import hello
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
name=dict(type='str'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exit_json(**say_hello(module.params['name']))
|
||||||
|
|
||||||
|
|
||||||
|
def say_hello(name):
|
||||||
|
return dict(
|
||||||
|
message=hello(name),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
- hello:
|
||||||
|
name: Ansibull
|
||||||
|
register: hello
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- hello.message == 'Hello Ansibull'
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
from .....plugins.module_utils.my_util import hello
|
||||||
|
|
||||||
|
|
||||||
|
def test_hello():
|
||||||
|
assert hello('Ansibull') == 'Hello Ansibull'
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
from .....plugins.modules.hello import say_hello
|
||||||
|
|
||||||
|
|
||||||
|
def test_say_hello():
|
||||||
|
assert say_hello('Ansibull') == dict(message='Hello Ansibull')
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
|
||||||
|
# tests must be executed outside of the ansible source tree
|
||||||
|
# otherwise ansible-test will test the ansible source instead of the test collection
|
||||||
|
# the temporary directory provided by ansible-test resides within the ansible source tree
|
||||||
|
tmp_dir=$(mktemp -d)
|
||||||
|
|
||||||
|
trap 'rm -rf "${tmp_dir}"' EXIT
|
||||||
|
|
||||||
|
cp -a ansible_collections "${tmp_dir}"
|
||||||
|
cd "${tmp_dir}/ansible_collections/ns/col"
|
||||||
|
|
||||||
|
# common args for all tests
|
||||||
|
common=(--venv --python "${ANSIBLE_TEST_PYTHON_VERSION}" --color --truncate 0 "${@}")
|
||||||
|
|
||||||
|
# prime the venv to work around issue with PyYAML detection in ansible-test
|
||||||
|
ansible-test sanity "${common[@]}" --test ignores
|
||||||
|
|
||||||
|
# tests
|
||||||
|
ansible-test sanity "${common[@]}"
|
||||||
|
ansible-test units "${common[@]}"
|
||||||
|
ansible-test integration "${common[@]}"
|
||||||
Loading…
Reference in New Issue