djLint/tests/test_golang.py
Christopher Pickering a10ac08686
added fix for #152
2021-11-29 12:19:07 +01:00

30 lines
818 B
Python

"""Djlint tests specific to go-lang.
run::
pytest tests/test_golang.py --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
for a single test, run::
pytest tests/test_golang.py::test_inline_comment --cov=src/djlint \
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
"""
# pylint: disable=C0116
from typing import TextIO
from click.testing import CliRunner
from .conftest import reformat
def test_if(runner: CliRunner, tmp_file: TextIO) -> None:
output = reformat(tmp_file, runner, b"{{ if .condition }} {{ else }} {{ end }}")
assert output.exit_code == 0
def test_range(runner: CliRunner, tmp_file: TextIO) -> None:
output = reformat(tmp_file, runner, b"{{ range .Items }} {{ end }}")
assert output.exit_code == 0