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
f03d6a67
Commit
f03d6a67
authored
Feb 24, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding new tests for assemble role
parent
0a83f743
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
100 additions
and
4 deletions
+100
-4
library/files/assemble
+2
-2
test/integration/non_destructive.yml
+2
-2
tests_new/integration/roles/test_assemble/files/fragment1
+1
-0
tests_new/integration/roles/test_assemble/files/fragment2
+1
-0
tests_new/integration/roles/test_assemble/files/fragment3
+1
-0
tests_new/integration/roles/test_assemble/files/fragment4
+1
-0
tests_new/integration/roles/test_assemble/files/fragment5
+1
-0
tests_new/integration/roles/test_assemble/meta/main.yml
+20
-0
tests_new/integration/roles/test_assemble/tasks/main.yml
+71
-0
No files found.
library/files/assemble
View file @
f03d6a67
...
...
@@ -107,7 +107,7 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None):
continue
fragment
=
"
%
s/
%
s"
%
(
src_path
,
f
)
if
delimit_me
and
delimiter
:
tmp
.
write
(
delimiter
)
tmp
.
write
(
"
%
s
\n
"
%
delimiter
)
if
os
.
path
.
isfile
(
fragment
):
tmp
.
write
(
file
(
fragment
)
.
read
())
delimit_me
=
True
...
...
@@ -171,7 +171,7 @@ def main():
file_args
=
module
.
load_file_common_arguments
(
module
.
params
)
changed
=
module
.
set_file_attributes_if_different
(
file_args
,
changed
)
# Mission complete
module
.
exit_json
(
src
=
src
,
dest
=
dest
,
md5sum
=
dest
md5
,
changed
=
changed
,
msg
=
"OK"
)
module
.
exit_json
(
src
=
src
,
dest
=
dest
,
md5sum
=
path
md5
,
changed
=
changed
,
msg
=
"OK"
)
# import module snippets
from
ansible.module_utils.basic
import
*
...
...
test/integration/non_destructive.yml
View file @
f03d6a67
...
...
@@ -17,6 +17,7 @@
-
{
role
:
test_file
,
tags
:
test_file
}
-
{
role
:
test_fetch
,
tags
:
test_fetch
}
-
{
role
:
test_synchronize
,
tags
:
test_synchronize
}
-
{
role
:
test_assemble
,
tags
:
test_assemble
}
-
{
role
:
test_subversion
,
tags
:
test_subversion
}
-
{
role
:
test_git
,
tags
:
test_git
}
-
{
role
:
test_hg
,
tags
:
test_hg
}
...
...
@@ -34,4 +35,4 @@
-
{
role
:
test_iterators
,
tags
:
test_iterators
}
-
{
role
:
test_command_shell
,
tags
:
test_command_shell
}
-
{
role
:
test_failed_when
,
tags
:
test_failed_when
}
-
{
role
:
test_script
,
tags
:
test_script
}
\ No newline at end of file
-
{
role
:
test_script
,
tags
:
test_script
}
tests_new/integration/roles/test_assemble/files/fragment1
0 → 100644
View file @
f03d6a67
this is fragment 1
tests_new/integration/roles/test_assemble/files/fragment2
0 → 100644
View file @
f03d6a67
this is fragment 2
tests_new/integration/roles/test_assemble/files/fragment3
0 → 100644
View file @
f03d6a67
this is fragment 3
tests_new/integration/roles/test_assemble/files/fragment4
0 → 100644
View file @
f03d6a67
this is fragment 4
tests_new/integration/roles/test_assemble/files/fragment5
0 → 100644
View file @
f03d6a67
this is fragment 5
tests_new/integration/roles/test_assemble/meta/main.yml
0 → 100644
View file @
f03d6a67
# test code for the assemble module
# (c) 2014, James Cammarata <jcammarata@ansible.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/>.
dependencies
:
-
prepare_tests
tests_new/integration/roles/test_assemble/tasks/main.yml
0 → 100644
View file @
f03d6a67
# test code for the assemble module
# (c) 2014, James Cammarata <jcammarata@ansible.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
:
create a new directory for file source
file
:
dest="{{output_dir}}/src" state=directory
register
:
result
-
name
:
assert the directory was created
assert
:
that
:
-
"
result.state
==
'directory'"
-
name
:
copy the files to a new directory
copy
:
src="./" dest="{{output_dir}}/src"
register
:
result
-
name
:
test assemble with all fragments
assemble
:
src="{{output_dir}}/src" dest="{{output_dir}}/assembled1"
register
:
result
-
name
:
assert the fragments were assembled
assert
:
that
:
-
"
result.state
==
'file'"
-
"
result.md5sum
==
'96905702a2ece40de6bf3a94b5062513'"
-
name
:
test assemble with fragments matching a regex
assemble
:
src="{{output_dir}}/src" dest="{{output_dir}}/assembled2" regexp="^fragment[1-3]$"
register
:
result
-
name
:
assert the fragments were assembled with a regex
assert
:
that
:
-
"
result.state
==
'file'"
-
"
result.md5sum
==
'eb9e3486a9cd6943b5242e573b9b9349'"
-
name
:
test assemble with a delimiter
assemble
:
src="{{output_dir}}/src" dest="{{output_dir}}/assembled3" delimiter="#--- delimiter ---#"
register
:
result
-
name
:
assert the fragments were assembled with a delimiter
assert
:
that
:
-
"
result.state
==
'file'"
-
"
result.md5sum
==
'4773eac67aba3f0be745876331c8a450'"
-
name
:
test assemble with remote_src=False
assemble
:
src="{{output_dir}}/src" dest="{{output_dir}}/assembled4" remote_src=False
register
:
result
-
name
:
assert the fragments were assembled without remote
assert
:
that
:
-
"
result.state
==
'file'"
-
"
result.md5sum
==
'96905702a2ece40de6bf3a94b5062513'"
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