Add testing mode
Closed this issue · 1 comments
Writing templates can be tedious with lots of try-and-error
It should be possible to render templates in a local non-Git directory and compare them with a given set of expected file contents.
With that, it's possible to write kind of "unit tests" of a template.
Proposed file structure:
.tests
└── case-1
└── README.adoc
tests
├── case-1
│ ├── README.adoc
│ └── .sync.yaml
└── tests.yaml
Test cases are put into arbitrary-named folders inside the tests
directory in a template repository.
Each of these folders all the files that are expected to be rendered.
The .sync.yaml
contains the template variables with the exact same syntax as .sync.yaml
for a managed repository (in fact it's treated as a repository).
The .tests
folder exists only after running gsync test
and contains the rendered files based on the files in tests
with the same directory structure.
The file tests/tests.yaml
may contain any global variables (similar to config_defaults.yaml
).
That way, the render process is almost exactly the same.