Skip to content

Commit

Permalink
Merge pull request #100 from jameinel/0.3-include-templates
Browse files Browse the repository at this point in the history
charmcraft/commands/build.py: include 'templates' directory
  • Loading branch information
facundobatista authored Jul 29, 2020
2 parents 5ca714a + 0d4c513 commit 88895c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion charmcraft/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
'metrics.yaml',
'actions.yaml',
'lxd-profile.yaml',
'version'
'templates',
'version',
]

# The file name and template for the dispatch script
Expand Down
19 changes: 19 additions & 0 deletions tests/commands/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,25 @@ def test_build_code_tree(tmp_path):
assert linked_entrypoint == build_dir / 'code_source' / 'crazycharm.py'


def test_build_code_includes_templates(tmp_path):
"""If 'templates' exists, it is included in the build tree."""
build_dir = tmp_path / BUILD_DIRNAME
build_dir.mkdir()

source_dir = tmp_path / "templates"
entrypoint = tmp_path / 'charm.py'
source_dir.mkdir()
builder = Builder({
'from': tmp_path,
'entrypoint': entrypoint,
'requirement': [],
})
builder.handle_code()
built_dir = build_dir / 'templates'
assert built_dir.is_symlink()
assert built_dir.resolve() == source_dir


def test_build_dispatcher_modern_dispatch_created(tmp_path):
"""The dispatcher script is properly built."""
build_dir = tmp_path / BUILD_DIRNAME
Expand Down

0 comments on commit 88895c9

Please sign in to comment.