Skip to content

Commit a838f2b

Browse files
committed
fix tests that called def outside module
1 parent d913c71 commit a838f2b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

apps/language_server/test/providers/plugins/ecto_test.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
356356
# TODO
357357
# test "list available bindings" do
358358
# buffer = """
359+
# defmodule Foo do
359360
# import Ecto.Query
360361
# alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.User, as: User
361362

@@ -370,6 +371,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
370371
# where: u.id == m
371372
# # ^ ^
372373
# end
374+
# end
373375
# """
374376

375377
# [cursor_1, cursor_2] = cursors(buffer)
@@ -390,6 +392,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
390392

391393
# test "list binding's fields" do
392394
# buffer = """
395+
# defmodule Foo do
393396
# import Ecto.Query
394397
# alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
395398
# alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Comment
@@ -403,6 +406,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
403406
# # ^ ^ ^ ^
404407
# )
405408
# end
409+
# end
406410
# """
407411

408412
# [cursor_1, cursor_2, cursor_3, cursor_4] = cursors(buffer)
@@ -429,6 +433,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
429433

430434
# test "list binding's fields even without any hint after `.`" do
431435
# buffer = """
436+
# defmodule Foo do
432437
# import Ecto.Query
433438
# alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
434439

@@ -440,6 +445,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
440445
# # ^
441446
# )
442447
# end
448+
# end
443449
# """
444450

445451
# [cursor] = cursors(buffer)
@@ -455,6 +461,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
455461

456462
test "list associations from assoc/2" do
457463
buffer = """
464+
defmodule Foo do
458465
import Ecto.Query
459466
alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
460467
@@ -465,6 +472,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
465472
# ^
466473
)
467474
end
475+
end
468476
"""
469477

470478
[cursor] = cursors(buffer)
@@ -492,6 +500,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
492500
# Code.ensure_loaded(ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Tag)
493501

494502
# buffer = """
503+
# defmodule Foo do
495504
# import Ecto.Query
496505
# alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
497506
# alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Comment
@@ -500,6 +509,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
500509
# from p in Post, join: c in Comment
501510
# # ^ ^
502511
# end
512+
# end
503513
# """
504514

505515
# [cursor_1, cursor_2] = cursors(buffer)
@@ -523,6 +533,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
523533

524534
test "list bindings and binding fields inside nested functions" do
525535
buffer = """
536+
defmodule Foo do
526537
import Ecto.Query
527538
alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
528539
@@ -533,6 +544,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
533544
# ^ ^
534545
)
535546
end
547+
end
536548
"""
537549

538550
[cursor_1, cursor_2] = cursors(buffer)
@@ -543,13 +555,15 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
543555

544556
test "list bindings and binding fields using full module name" do
545557
buffer = """
558+
defmodule Foo do
546559
import Ecto.Query
547560
548561
def query() do
549562
from p in ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post,
550563
where: p.t
551564
# ^ ^
552565
end
566+
end
553567
"""
554568

555569
[cursor_1, cursor_2] = cursors(buffer)
@@ -560,34 +574,39 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
560574

561575
test "from/2 without parens" do
562576
buffer = """
577+
defmodule Foo do
563578
import Ecto.Query
564579
alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
565580
566581
def query() do
567582
from p in Post, se
568583
# ^
569584
end
585+
end
570586
"""
571587

572588
[cursor] = cursors(buffer)
573589

574590
assert [%{label: "select"}, %{label: "select_merge"}] = suggestions(buffer, cursor)
575591

576592
buffer = """
593+
defmodule Foo do
577594
import Ecto.Query
578595
alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
579596
580597
def query() do
581598
from p in Post, where: p.id
582599
# ^
583600
end
601+
end
584602
"""
585603

586604
[cursor] = cursors(buffer)
587605

588606
assert [%{label: "id"}] = suggestions(buffer, cursor)
589607

590608
buffer = """
609+
defmodule Foo do
591610
import Ecto.Query
592611
alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
593612
@@ -597,13 +616,15 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
597616
se
598617
# ^
599618
end
619+
end
600620
"""
601621

602622
[cursor] = cursors(buffer)
603623

604624
assert [%{label: "select"}, %{label: "select_merge"}] = suggestions(buffer, cursor)
605625

606626
buffer = """
627+
defmodule Foo do
607628
import Ecto.Query
608629
alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
609630
@@ -613,6 +634,7 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
613634
614635
# ^
615636
end
637+
end
616638
"""
617639

618640
[cursor] = cursors(buffer)
@@ -622,13 +644,15 @@ defmodule ElixirLS.LanguageServer.Plugins.EctoTest do
622644

623645
test "succeeds when using schema with many_to_many assoc" do
624646
buffer = """
647+
defmodule Foo do
625648
import Ecto.Query
626649
alias ElixirLS.LanguageServer.Plugins.Ecto.FakeSchemas.Post
627650
628651
def query() do
629652
from p in Post, se
630653
# ^
631654
end
655+
end
632656
"""
633657

634658
[cursor] = cursors(buffer)

0 commit comments

Comments
 (0)