forked from tconbeer/sqlfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_query.py
More file actions
24 lines (17 loc) · 867 Bytes
/
Copy pathtest_query.py
File metadata and controls
24 lines (17 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pytest
from sqlfmt.analyzer import Analyzer
def test_whitespace_formatting(default_analyzer: Analyzer) -> None:
source_string = " select 1\n from my_table\nwhere true"
expected_string = "select 1\nfrom my_table\nwhere true\n"
q = default_analyzer.parse_query(source_string=source_string)
assert str(q) == expected_string
def test_only_comment_formatting(default_analyzer: Analyzer) -> None:
source_string = "-- a comment"
expected_string = "-- a comment\n"
q = default_analyzer.parse_query(source_string=source_string)
assert str(q) == expected_string
@pytest.mark.parametrize("source_string", ["", "\n"])
def test_empty_formatting(default_analyzer: Analyzer, source_string: str) -> None:
expected_string = ""
q = default_analyzer.parse_query(source_string=source_string)
assert str(q) == expected_string