Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unit tests that were broken before 1.13 #749

Merged
merged 1 commit into from
Oct 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions apps/language_server/test/source_file/invalid_project_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ defmodule ElixirLS.LanguageServer.SourceFile.InvalidProjectTest do
alias ElixirLS.LanguageServer.SourceFile
import ExUnit.CaptureLog

def appropriate_formatter_function_name(_) do
formatter_function =
if function_exported?(Mix.Tasks.Format, :formatter_for_file, 1) do
:formatter_for_file
else
:formatter_opts_for_file
end

{:ok, formatter_name: formatter_function}
end

describe "formatter_for " do
test "should handle syntax errors" do
patch(Mix.Tasks.Format, :formatter_for_file, fn _ ->
setup [:appropriate_formatter_function_name]

test "should handle syntax errors", ctx do
patch(Mix.Tasks.Format, ctx.formatter_name, fn _ ->
raise %SyntaxError{file: ".formatter.exs", line: 1}
end)

Expand All @@ -19,8 +32,8 @@ defmodule ElixirLS.LanguageServer.SourceFile.InvalidProjectTest do
assert String.contains?(output, "Unable to get formatter options")
end

test "should handle compile errors" do
patch(Mix.Tasks.Format, :formatter_for_file, fn _ ->
test "should handle compile errors", ctx do
patch(Mix.Tasks.Format, ctx.formatter_name, fn _ ->
raise %SyntaxError{file: ".formatter.exs", line: 1}
end)

Expand Down