From 08b8ac8360a0a73c8389521512b57a09ecdc33b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 29 Aug 2022 11:35:40 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20test=20to=20check=20that=20ex?= =?UTF-8?q?presion.py=20is=20in=20sync=20with=20Jinja2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/generate_select.py | 8 ++++++++ scripts/test.sh | 1 + 2 files changed, 9 insertions(+) diff --git a/scripts/generate_select.py b/scripts/generate_select.py index b66a1673c4..f8aa30023f 100644 --- a/scripts/generate_select.py +++ b/scripts/generate_select.py @@ -1,3 +1,4 @@ +import os from itertools import product from pathlib import Path from typing import List, Tuple @@ -52,4 +53,11 @@ class Arg(BaseModel): result = black.format_str(result, mode=black.Mode()) +current_content = destiny_path.read_text() + +if current_content != result and os.getenv("CHECK_JINJA"): + raise RuntimeError( + "sqlmodel/sql/expression.py content not update with Jinja2 template" + ) + destiny_path.write_text(result) diff --git a/scripts/test.sh b/scripts/test.sh index 7fce865bd6..1887dc9949 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -3,6 +3,7 @@ set -e set -x +CHECK_JINJA=1 python scripts/generate_select.py coverage run -m pytest tests coverage combine coverage report --show-missing