GenLSP.Test (gen_lsp v0.0.5)
Conveniences for testing GenLSP processes.
Link to this section Summary
Functions
Simple helper to determine whether the LSP process is alive.
Assert on a notification that was sent from the server.
Assert on the response of a request that was sent with GenLSP.Test.request/2
.
Starts a new LSP client for the given server.
Send a notification from the client to the server.
Send a request from the client to the server.
Starts a new server.
Link to this section Types
@opaque client()
The test client data structure.
@opaque server()
The test server data structure.
Link to this section Functions
alive?(map)
Simple helper to determine whether the LSP process is alive.
Assert on a notification that was sent from the server.
The second argument is a pattern, similar to ExUnit.Assertions.assert_receive/3
.
usage
Usage
import GenLSP.Test
notify(client, %{method: "initialized", jsonrpc: "2.0", params: %{}})
assert_notification("window/logMessage", %{
"message" => "[MyLSP] LSP Initialized!",
"type" => 4
})
Assert on the response of a request that was sent with GenLSP.Test.request/2
.
The second argument is a pattern, similar to ExUnit.Assertions.assert_receive/3
.
usage
Usage
import GenLSP.Test
request(client, %{
method: "initialize",
id: 1,
jsonrpc: "2.0",
params: %{capabilities: %{}, rootUri: "file://#{root_path}"}
})
assert_result(1, %{
"capabilities" => %{
"textDocumentSync" => %{
"openClose" => true,
"save" => %{
"includeText" => true
},
"change" => 1
}
},
"serverInfo" => %{"name" => "Credo"}
})
client(server)
Starts a new LSP client for the given server.
The "client" is equivalent to a text editor.
usage
Usage
import GenLSP.Test
server = server(MyLSP, some_arg: some_arg)
client = client(server)
notify(map, body)
@spec notify(client(), Jason.Encoder.t()) :: :ok
Send a notification from the client to the server.
usage
Usage
import GenLSP.Test
notify(client, %{
method: "initialized",
jsonrpc: "2.0",
params: %{}
})
request(map, body)
@spec request(client(), Jason.Encoder.t()) :: {:ok, any()}
Send a request from the client to the server.
The response from the server will be sent as a message to the current process and can be asserted on using GenLSP.Test.assert_result/3
.
usage
Usage
import GenLSP.Test
request(client, %{
method: "initialize",
id: 1,
jsonrpc: "2.0",
params: %{capabilities: %{}, rootUri: "file://#{root_path}"}
})
server(mod, opts \\ [])
Starts a new server.
usage
Usage
import GenLSP.Test
server = server(MyLSP, some_arg: some_arg)