Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
b2e59038
Commit
b2e59038
authored
Feb 20, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some missing files for filters and ignore_errors tests
parent
fa1ab231
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
185 additions
and
0 deletions
+185
-0
tests_new/integration/roles/test_filters/files/foo.txt
+73
-0
tests_new/integration/roles/test_filters/meta/main.yml
+3
-0
tests_new/integration/roles/test_filters/tasks/main.yml
+40
-0
tests_new/integration/roles/test_filters/templates/foo.j2
+60
-0
tests_new/integration/roles/test_filters/vars/main.yml
+6
-0
tests_new/integration/roles/test_ignore_errors/meta/main.yml
+3
-0
No files found.
tests_new/integration/roles/test_filters/files/foo.txt
0 → 100644
View file @
b2e59038
This is a test of various filter plugins found in Ansible (ex: core.py), and
not so much a test of the core filters in Jinja2.
Dumping a nested structure to JSON
[
"this is a list element",
{
"this": "is a hash element in a list",
"warp": 9,
"where": "endor"
}
]
Dumping the same structure to YAML
- this is a list element
- this: is a hash element in a list
warp: 9
where: endor
Dumping the same structure to JSON, but don't pretty print
["this is a list element", {"this": "is a hash element in a list", "where": "endor", "warp": 9}]
Dumping the same structure to YAML, but don't pretty print
- this is a list element
- {this: is a hash element in a list, warp: 9, where: endor}
From a recorded task, the changed, failed, success, and skipped
filters are shortcuts to ask if those tasks produced changes, failed,
succeeded, or skipped (as one might guess).
Changed = True
Failed = False
Success = True
Skipped = False
The mandatory filter fails if a variable is not defined and returns the value.
To avoid breaking this test, this variable is already defined.
a = 1
There are various casts available
int = 1
bool = True
String quoting
quoted = quoted
The fileglob module returns the list of things matching a pattern.
fileglob = []
There are also various string operations that work on paths. These do not require
files to exist and are passthrus to the python os.path functions
'~/foo' with expanduser = /root/foo
/etc/motd with basename = motd
/etc/motd with dirname = /etc
TODO: realpath follows symlinks. There isn't a test for this just now.
TODO: add tests for set theory operations like union
TODO: add tests for regex, match, and search
tests_new/integration/roles/test_filters/meta/main.yml
0 → 100644
View file @
b2e59038
dependencies
:
-
prepare_tests
tests_new/integration/roles/test_filters/tasks/main.yml
0 → 100644
View file @
b2e59038
# test code
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
name
:
a dummy task to test the changed and success filters
shell
:
echo hi
register
:
some_registered_var
-
debug
:
var=some_registered_var
-
name
:
fill in a basic template
template
:
src=foo.j2 dest={{output_dir}}/foo.templated mode=0644
register
:
template_result
-
name
:
copy known good into place
copy
:
src=foo.txt dest={{output_dir}}/foo.txt
-
name
:
compare templated file to known good
shell
:
diff {{output_dir}}/foo.templated {{output_dir}}/foo.txt
register
:
diff_result
-
name
:
verify templated file matches known good
assert
:
that
:
-
'
diff_result.stdout
==
""'
tests_new/integration/roles/test_filters/templates/foo.j2
0 → 100644
View file @
b2e59038
This is a test of various filter plugins found in Ansible (ex: core.py), and
not so much a test of the core filters in Jinja2.
Dumping a nested structure to JSON
{{ some_structure | to_nice_json }}
Dumping the same structure to YAML
{{ some_structure | to_nice_yaml }}
Dumping the same structure to JSON, but don't pretty print
{{ some_structure | to_json }}
Dumping the same structure to YAML, but don't pretty print
{{ some_structure | to_yaml }}
From a recorded task, the changed, failed, success, and skipped
filters are shortcuts to ask if those tasks produced changes, failed,
succeeded, or skipped (as one might guess).
Changed = {{ some_registered_var | changed }}
Failed = {{ some_registered_var | failed }}
Success = {{ some_registered_var | success }}
Skipped = {{ some_registered_var | skipped }}
The mandatory filter fails if a variable is not defined and returns the value.
To avoid breaking this test, this variable is already defined.
a = {{ a | mandatory }}
There are various casts available
int = {{ a | int }}
bool = {{ 1 | bool }}
String quoting
quoted = {{ 'quoted' | quote }}
The fileglob module returns the list of things matching a pattern.
fileglob = {{ (output_dir + '/*') | fileglob }}
There are also various string operations that work on paths. These do not require
files to exist and are passthrus to the python os.path functions
'~/foo' with expanduser = {{ '~/foo' | expanduser }}
/etc/motd with basename = {{ '/etc/motd' | basename }}
/etc/motd with dirname = {{ '/etc/motd' | dirname }}
TODO: realpath follows symlinks. There isn't a test for this just now.
TODO: add tests for set theory operations like union
TODO: add tests for regex, match, and search
tests_new/integration/roles/test_filters/vars/main.yml
0 → 100644
View file @
b2e59038
some_structure
:
-
"
this
is
a
list
element"
-
this
:
"
is
a
hash
element
in
a
list"
warp
:
9
where
:
endor
tests_new/integration/roles/test_ignore_errors/meta/main.yml
0 → 100644
View file @
b2e59038
dependencies
:
-
prepare_tests
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment