Skip to content

Commit c0c0dfb

Browse files
committed
Add unittests for error posting
1 parent 4806556 commit c0c0dfb

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/test_server_messages.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from setup_tests import run_request, test_dir, write_rpc_request
2+
3+
4+
def check_msg(ref, res):
5+
assert ref["type"] == res["type"]
6+
assert ref["message"] == res["message"]
7+
8+
9+
# def test_config_file_non_existent():
10+
# string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
11+
# errcode, results = run_request(string, ["-c", "fake.json"])
12+
#
13+
# ref = {"type": 1, "message": "Configuration file 'fake.json' not found"}
14+
# assert errcode == 0
15+
# check_msg(ref, results[0])
16+
17+
18+
def test_config_file_non_existent_options():
19+
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
20+
errcode, results = run_request(string, ["-c", "wrong_syntax.json"])
21+
22+
ref = {
23+
"type": 1,
24+
"message": (
25+
"Error: 'Expecting ':' delimiter: line 2 column 18 (char 19)' while reading"
26+
" 'wrong_syntax.json' Configuration file"
27+
),
28+
}
29+
assert errcode == 0
30+
check_msg(ref, results[0])

test/test_source/wrong_syntax.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"source_dirs", "s"
3+
}

0 commit comments

Comments
 (0)