Skip to content

Commit 9a28fc3

Browse files
committed
ra-multiplex: More tests
1 parent 7432eda commit 9a28fc3

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

Formula/ra-multiplex.rb

+53-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,59 @@ def install
3232
environment_variables PATH: "#{std_service_path_env}:#{Dir.home}/.cargo/bin"
3333
end
3434

35+
def rpc(json)
36+
"Content-Length: #{json.size}\r\n" \
37+
"\r\n" \
38+
"#{json}"
39+
end
40+
3541
test do
36-
assert_equal "ra-multiplex #{version}", shell_output("#{bin}/ra-multiplex --version").chomp
42+
input = rpc <<~JSON
43+
{
44+
"jsonrpc":"2.0",
45+
"id":1,
46+
"method":"initialize",
47+
"params": {
48+
"rootUri": null,
49+
"initializationOptions": {},
50+
"capabilities": {}
51+
}
52+
}
53+
JSON
54+
55+
input += rpc <<~JSON
56+
{
57+
"jsonrpc":"2.0",
58+
"method":"initialized",
59+
"params": {}
60+
}
61+
JSON
62+
63+
input += rpc <<~JSON
64+
{
65+
"jsonrpc":"2.0",
66+
"id": 2,
67+
"method":"shutdown",
68+
"params": null
69+
}
70+
JSON
71+
72+
input += rpc <<~JSON
73+
{
74+
"jsonrpc":"2.0",
75+
"method":"exit",
76+
"params": {}
77+
}
78+
JSON
79+
80+
output = /Content-Length: \d+\r\n\r\n/
81+
82+
begin
83+
pid = spawn bin/"ra-multiplex", "server"
84+
assert_match output, pipe_output(bin/"ra-multiplex", input, 0)
85+
ensure
86+
Process.kill("TERM", pid)
87+
Process.wait(pid)
88+
end
3789
end
3890
end

0 commit comments

Comments
 (0)