@@ -285,6 +285,29 @@ def test_ensure_alt_path(runner, paths, style):
285285 assert run .out == ''
286286 assert paths .work .join (filename ).read ().strip () == 'test-data'
287287
288+ @pytest .mark .usefixtures ("ds1_repo_copy" )
289+ @pytest .mark .parametrize ("readonly" , [None , "true" , "false" ])
290+ def test_template_readonly (runner , yadm_cmd , paths , tst_sys , readonly ):
291+ """Remove symlinks before processing a template
292+
293+ If a symlink is in the way of the output of a template, the target of the
294+ symlink will get the template content. To prevent this, the symlink should
295+ be removed just before processing a template.
296+ """
297+ # set the value of template read-only
298+ if readonly :
299+ runner (yadm_cmd ("config" , "yadm.template-read-only" , readonly ))
300+
301+ utils .create_alt_files (paths , f"##template.default" )
302+ run = runner (yadm_cmd ("alt" ))
303+
304+ for stale_path in [utils .ALT_FILE1 , utils .ALT_FILE2 ]:
305+ write_perm_mask = os .stat (paths .work .join (stale_path )).st_mode & 0o222
306+ if readonly == "false" :
307+ assert write_perm_mask > 0
308+ else :
309+ assert write_perm_mask == 0
310+
288311
289312def setup_standard_yadm_dir (paths ):
290313 """Configure a yadm home within the work tree"""
0 commit comments