Skip to content

Commit

Permalink
add testhelper for local update
Browse files Browse the repository at this point in the history
Summary: these helper functions make these tests way easier to read. I did this when writing some tests today and figured we should keep it.

Reviewed By: connernilsen

Differential Revision: D50747692

fbshipit-source-id: 93b6afe8e5928badd841c7f7e811739ead44da68
  • Loading branch information
kinto0 authored and facebook-github-bot committed Oct 27, 2023
1 parent 30fc317 commit 2628a89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 4 additions & 11 deletions source/code_navigation_server/test/basicTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,10 @@ let test_file_and_local_update context =
open_file ~path:(PyrePath.absolute test_path) ~client_id;
open_file ~path:(PyrePath.absolute test2_path) ~client_id;
assert_type_error_count_for_path ~path:(PyrePath.absolute test_path) ~client_id ~expected:2;
ScratchProject.ClientConnection.assert_response
~request:
Request.(
Command
(Command.LocalUpdate
{
path = PyrePath.absolute test_path;
content = Some "from test2 import x";
client_id;
}))
~expected:Response.Ok;
local_update
~path:(PyrePath.absolute test_path)
~content:(Some "from test2 import x")
~client_id;
assert_type_error_count_for_path ~path:(PyrePath.absolute test_path) ~client_id ~expected:1;
(fun _ ->
File.create test2_path ~content:"x: int = 42" |> File.write;
Expand Down
6 changes: 6 additions & 0 deletions source/code_navigation_server/test/testHelper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ let close_file ~client_id ~path =
~expected:Response.Ok


let local_update ~client_id ~path ~content =
ScratchProject.ClientConnection.assert_response
~request:Request.(Command (Command.LocalUpdate { path; client_id; content }))
~expected:Response.Ok


let assert_type_error_count ~client_id ~path ~expected client =
let%lwt raw_response =
ScratchProject.ClientConnection.send_request
Expand Down

0 comments on commit 2628a89

Please sign in to comment.