Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for WANT_JSON and old style modules #50555

Merged
merged 8 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
if [ -f "$1" ]; then
. "$1"
else
echo '{"msg": "No argument file provided", "failed": True}'
echo '{"msg": "No argument file provided", "failed": true}'
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this module includes an error check for no argument file, I'd include testing that in the integration test. Just execute it as a script instead of a module to verify it fails as expected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in the latest commit


Expand Down
11 changes: 11 additions & 0 deletions test/integration/targets/old_style_modules_posix/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@
- assert:
that:
- 'goodbye_ansible.msg == "Goodbye, Ansible!"'

- name: Execute module directly
command: '/bin/sh {{ role_path }}/library/helloworld.sh'
register: direct
ignore_errors: true

- assert:
that:
- direct is failed
- |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the multi-line syntax here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had done it originally due to simplifying quoting, but after a change it's no longer needed, I just didn't remove it. It wasn't done for multiline, but rather as a block literal, to avoid the need for outer quotes which would have complicated things.

direct.stdout == '{"msg": "No argument file provided", "failed": true}'
11 changes: 11 additions & 0 deletions test/integration/targets/want_json_modules_posix/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@
- assert:
that:
- 'goodbye_ansible.msg == "Goodbye, Ansible!"'

- name: Execute module directly
command: '{{ ansible_python_interpreter|default(ansible_playbook_python) }} {{ role_path }}/library/helloworld.py'
register: direct
ignore_errors: true

- assert:
that:
- direct is failed
- |
direct.stdout == '{"msg": "No argument file provided", "failed": true}'