summaryrefslogtreecommitdiffhomepage
path: root/test/test_configuration.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2020-03-25 19:40:08 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2020-03-25 19:40:08 +0000
commit8532cf6ae6e9ed7d03dd7e06e36eee63fd9d6ceb (patch)
treec3986402a7ad0eff3138159c1c8bb6331d16285f /test/test_configuration.py
parent2e4ad9fbc07a2ed408c017df93e5116d97a221e9 (diff)
downloadunit-8532cf6ae6e9ed7d03dd7e06e36eee63fd9d6ceb.tar.gz
unit-8532cf6ae6e9ed7d03dd7e06e36eee63fd9d6ceb.tar.bz2
Tests: added tests for comments in JSON.
Diffstat (limited to 'test/test_configuration.py')
-rw-r--r--test/test_configuration.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/test_configuration.py b/test/test_configuration.py
index 2acb7ccd..daba874b 100644
--- a/test/test_configuration.py
+++ b/test/test_configuration.py
@@ -102,6 +102,67 @@ class TestConfiguration(TestControl):
'UTF-8 BOM',
)
+ def test_json_comment_single_line(self):
+ self.assertIn(
+ 'success',
+ self.conf(
+ b"""
+ // this is bridge
+ {
+ "//app": {
+ "type": "python", // end line
+ "processes": {"spare": 0},
+ // inside of block
+ "path": "/app",
+ "module": "wsgi"
+ }
+ // double //
+ }
+ // end of json \xEF\t
+ """,
+ 'applications',
+ ),
+ 'single line comments',
+ )
+
+ def test_json_comment_multi_line(self):
+ self.assertIn(
+ 'success',
+ self.conf(
+ b"""
+ /* this is bridge */
+ {
+ "/*app": {
+ /**
+ * multiple lines
+ **/
+ "type": "python",
+ "processes": /* inline */ {"spare": 0},
+ "path": "/app",
+ "module": "wsgi"
+ /*
+ // end of block */
+ }
+ /* blah * / blah /* blah */
+ }
+ /* end of json \xEF\t\b */
+ """,
+ 'applications',
+ ),
+ 'multi line comments',
+ )
+
+ def test_json_comment_invalid(self):
+ self.assertIn('error', self.conf(b'/{}', 'applications'), 'slash')
+ self.assertIn('error', self.conf(b'//{}', 'applications'), 'comment')
+ self.assertIn('error', self.conf(b'{} /', 'applications'), 'slash end')
+ self.assertIn(
+ 'error', self.conf(b'/*{}', 'applications'), 'slash star'
+ )
+ self.assertIn(
+ 'error', self.conf(b'{} /*', 'applications'), 'slash star end'
+ )
+
def test_applications_open_brace(self):
self.assertIn('error', self.conf('{', 'applications'), 'open brace')