11defmodule Expert.ExpertTest do
2+ alias Expert.State
3+ alias Forge.Test.Fixtures
4+
25 use ExUnit.Case , async: true
36 use Patch
47
@@ -8,15 +11,39 @@ defmodule Expert.ExpertTest do
811 with_patched_transport ( )
912
1013 assigns = start_supervised! ( GenLSP.Assigns , id: make_ref ( ) )
11- GenLSP.Assigns . merge ( assigns , % { state: % { } } )
14+ project = Fixtures . project ( )
15+
16+ root_uri = project . root_uri
17+ root_path = Forge.Project . root_path ( project )
18+
19+ request = % GenLSP.Requests.Initialize {
20+ id: 1 ,
21+ jsonrpc: "2.0" ,
22+ method: "initialize" ,
23+ params: % GenLSP.Structures.InitializeParams {
24+ capabilities: % GenLSP.Structures.ClientCapabilities { } ,
25+ process_id: "" ,
26+ root_uri: root_uri ,
27+ root_path: root_path ,
28+ workspace_folders: [
29+ % GenLSP.Structures.WorkspaceFolder {
30+ name: root_path ,
31+ uri: root_uri
32+ }
33+ ]
34+ }
35+ }
36+
37+ { :ok , _response , state } = State . initialize ( State . new ( ) , request )
38+ GenLSP.Assigns . merge ( assigns , % { state: state } )
1239
1340 lsp = % GenLSP.LSP { mod: Expert , assigns: assigns }
1441
1542 reason = :something_bad
1643
1744 assert { :noreply , ^ lsp } = Expert . handle_info ( { :engine_initialized , { :error , reason } } , lsp )
1845
19- error_message = "Failed to initialize: #{ inspect ( reason ) } "
46+ error_message = "[Project #{ project . root_uri } ] Failed to initialize: #{ inspect ( reason ) } "
2047 error_message_type = GenLSP.Enumerations.MessageType . error ( )
2148
2249 assert_receive { :transport ,
0 commit comments