Skip to content

Commit 64810d5

Browse files
author
Étienne Lévesque
committed
Add server test
1 parent 26fe78e commit 64810d5

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule TestCodeLens.MixProject do
2+
use Mix.Project
3+
4+
def project do
5+
[app: :references, version: "0.1.0"]
6+
end
7+
8+
def application, do: []
9+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
defmodule TestCodeLensTest do
2+
use ExUnit.Case
3+
4+
test "fixture test" do
5+
assert true
6+
end
7+
end

apps/language_server/test/server_test.exs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,63 @@ defmodule ElixirLS.LanguageServer.ServerTest do
621621
end)
622622
end
623623

624+
@tag debug: true
625+
test "returns code lenses for runnable tests", %{server: server} do
626+
in_fixture(__DIR__, "test_code_lens", fn ->
627+
file_path = "test/fixture_test.exs"
628+
file_uri = SourceFile.path_to_uri(file_path)
629+
file_absolute_path = SourceFile.path_from_uri(file_uri)
630+
text = File.read!(file_path)
631+
632+
initialize(server)
633+
Server.receive_packet(server, did_open(file_uri, "elixir", 1, text))
634+
635+
Server.receive_packet(
636+
server,
637+
code_lens_req(4, file_uri)
638+
)
639+
640+
# :timer.sleep(1000)
641+
# %{"result" => resp} = assert_received(%{"id" => 4})
642+
resp = assert_receive(%{"id" => 4}, 5000)
643+
644+
assert response(4, [
645+
%{
646+
"command" => %{
647+
"arguments" => [
648+
%{
649+
"filePath" => ^file_absolute_path,
650+
"testName" => "fixture test"
651+
}
652+
],
653+
"command" => "elixir.lens.test.run",
654+
"title" => "Run test"
655+
},
656+
"range" => %{
657+
"end" => %{"character" => 0, "line" => 3},
658+
"start" => %{"character" => 0, "line" => 3}
659+
}
660+
},
661+
%{
662+
"command" => %{
663+
"arguments" => [
664+
%{
665+
"filePath" => file_absolute_path,
666+
"module" => "Elixir.TestCodeLensTest"
667+
}
668+
],
669+
"command" => "elixir.lens.test.run",
670+
"title" => "Run tests in module"
671+
},
672+
"range" => %{
673+
"end" => %{"character" => 0, "line" => 0},
674+
"start" => %{"character" => 0, "line" => 0}
675+
}
676+
}
677+
]) = resp
678+
end)
679+
end
680+
624681
defp with_new_server(func) do
625682
server = start_supervised!({Server, nil})
626683
packet_capture = start_supervised!({PacketCapture, self()})

0 commit comments

Comments
 (0)