Incidental coverage 1 (#77846)

* Add find test to assert patterns with regex

* Add test to assert that nested includes with relative path work

* Add test to assert symmetric_difference supports unhashable types

* ci_complete ci_coverage

* Add test to assert JSON values are converted to Python

* Add test to assert how unexpected module failures behave

* Add test to verify remote_is_local

* ci_complete ci_coverage

* Get real path of local tmp

* ci_complete ci_coverage

* Expanded symmetric_difference tests

* ci_complete ci_coverage

* I don't even know

* ci_complete ci_coverage

* Revert mathstuff changes

* ci_complete ci_coverage
pull/77916/head
Matt Martz 2 years ago committed by GitHub
parent f7d7604454
commit e7e1d592a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
shippable/posix/group3
context/controller

@ -0,0 +1,25 @@
# 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 = '''
name: remote_is_local
short_description: remote is local
description:
- remote_is_local
author: ansible (@core)
version_added: historical
extends_documentation_fragment:
- connection_pipelining
notes:
- The remote user is ignored, the user with which the ansible CLI was executed is used instead.
'''
from ansible.plugins.connection.local import Connection as LocalConnection
class Connection(LocalConnection):
_remote_is_local = True

@ -0,0 +1,15 @@
- command: ansible-playbook {{ role_path }}/test.yml -vvv -i {{ '-i '.join(ansible_inventory_sources) }}
environment:
ANSIBLE_REMOTE_TEMP: /i/dont/exist
ANSIBLE_NOCOLOR: 'true'
register: result
- assert:
that:
- >-
result.stdout is search('PUT ' ~ ansible_local ~ ' TO ' ~ ansible_local)
- >-
'/i/dont/exist' not in result.stdout
vars:
local_tmp: '{{ q("config", "remote_tmp", plugin_type="shell", plugin_name="sh")|first|expanduser|realpath }}'
ansible_local: '{{ local_tmp }}/ansible-local-\S+'

@ -0,0 +1,8 @@
- hosts: testhost
gather_facts: false
tasks:
- ping:
vars:
ansible_connection: remote_is_local
ansible_pipelining: false
ansible_remote_tmp: /i/dont/exist

@ -252,6 +252,7 @@
# dir contents are considered until the depth exceeds the requested depth
# there are 8 files/directories in the requested depth and 4 that exceed it by 1
- files_with_depth.examined == 12
- name: exclude with regex
find:
paths: "{{ remote_tmp_dir_test }}"
@ -268,6 +269,19 @@
that:
- '"{{ remote_tmp_dir_test }}/e/f/g/h/8.ogg" not in find_test3_list'
- name: patterns with regex
find:
paths: "{{ remote_tmp_dir_test }}"
recurse: yes
use_regex: true
patterns: .*\.ogg
register: find_test4
- name: assert we matched the ogg file
assert:
that:
- remote_tmp_dir_test ~ "/e/f/g/h/8.ogg" in find_test4.files|map(attribute="path")
- name: create our age/size testing sub-directory
file:
path: "{{ remote_tmp_dir_test }}/astest"

@ -0,0 +1,2 @@
shippable/posix/group5
context/controller

@ -0,0 +1,11 @@
- include_tasks: nested/nested_include.yml
- assert:
that:
- nested_adjacent_count|int == 1
- import_tasks: nested/nested_import.yml
- assert:
that:
- nested_adjacent_count|int == 2

@ -0,0 +1,2 @@
- set_fact:
nested_adjacent_count: '{{ nested_adjacent_count|default(0)|int + 1 }}'

@ -6,3 +6,13 @@
- result.stdout_lines|first == expected
vars:
expected: !unsafe '{{ foo }}'
- name: Assert that templating can convert JSON null, true, and false to Python
assert:
that:
- foo.null is none
- foo.true is true
- foo.false is false
vars:
# Kind of hack to just send a JSON string through jinja, by templating out nothing
foo: '{{ "" }}{"null": null, "true": true, "false": false}'

@ -0,0 +1,8 @@
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
TRANSFERS_FILES = False
def run(self, tmp=None, task_vars=None):
raise Exception('boom')

@ -0,0 +1,2 @@
shippable/posix/group3
context/controller

@ -0,0 +1,7 @@
- unexpected:
register: result
ignore_errors: true
- assert:
that:
- 'result.msg == "Unexpected failure during module execution: boom"'
Loading…
Cancel
Save