Skip to content

Commit 66f8a7a

Browse files
committed
Make tests for #15, #11
1 parent 3f9f52b commit 66f8a7a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test_nginxfmt.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,27 @@ def test_loading_latin1_file(self):
247247
# todo perform some tests on result file
248248
tmp_file.unlink()
249249

250+
def test_issue_15(self):
251+
self._check_formatting(
252+
'section { server_name "~^(?<tag>[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12})\.a\.b\.com$"; }',
253+
'section {\n server_name "~^(?<tag>[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12})\.a\.b\.com$";\n}\n')
254+
255+
def test_issue_11(self):
256+
self._check_formatting(" # 3 spaces\n" +
257+
"# 2 spaces\n" +
258+
" # 1 space",
259+
"# 3 spaces\n" +
260+
"# 2 spaces\n" +
261+
"# 1 space\n")
262+
263+
# everything after # is left as is (except trimming trailing whitespaces)
264+
self._check_formatting(""" #if (!-f $request_filename) {
265+
# rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
266+
#""",
267+
"#if (!-f $request_filename) {\n" +
268+
"# rewrite ^/static/?(.*)$ /static.php?resource=$1 last;\n" +
269+
"#\n")
270+
250271

251272
if __name__ == '__main__':
252273
unittest.main()

0 commit comments

Comments
 (0)