mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Add assemble module
This adds a module that concatenates (ie. assembles) a file from fragments in a directory in alphabetical order. It chains the file module afterward to fix up ownership and permission. This also adds tests for the assemble module with fragments in assemble.d.
This commit is contained in:
@@ -231,5 +231,28 @@ class TestRunner(unittest.TestCase):
|
||||
def test_service(self):
|
||||
# TODO: tests for the service module
|
||||
pass
|
||||
def test_assemble(self):
|
||||
input = self._get_test_file('assemble.d')
|
||||
metadata = self._get_test_file('metadata.json')
|
||||
output = self._get_stage_file('sample.out')
|
||||
result = self._run('assemble', [
|
||||
"src=%s" % input,
|
||||
"dest=%s" % output,
|
||||
"metadata=%s" % metadata
|
||||
])
|
||||
assert os.path.exists(output)
|
||||
out = file(output).read()
|
||||
assert out.find("first") != -1
|
||||
assert out.find("second") != -1
|
||||
assert out.find("third") != -1
|
||||
assert result['changed'] == True
|
||||
assert 'md5sum' in result
|
||||
assert 'failed' not in result
|
||||
result = self._run('assemble', [
|
||||
"src=%s" % input,
|
||||
"dest=%s" % output,
|
||||
"metadata=%s" % metadata
|
||||
])
|
||||
assert result['changed'] == False
|
||||
|
||||
|
||||
|
||||
2
test/assemble.d/00-source.txt
Normal file
2
test/assemble.d/00-source.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
# This is the first comment.
|
||||
[somegroup]
|
||||
2
test/assemble.d/01-source.txt
Normal file
2
test/assemble.d/01-source.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
# This is the second comment.
|
||||
127.0.0.2
|
||||
4
test/assemble.d/02.source.txt
Normal file
4
test/assemble.d/02.source.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
# This is the third comment.
|
||||
[somegroup:vars]
|
||||
foo=bar
|
||||
# 無 可 無 非 常 無
|
||||
Reference in New Issue
Block a user