Skip to content

Commit

Permalink
Ecto.Repo.all -> Ecto.Repo.all_running
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 27, 2021
1 parent d9b2f1a commit 0d5a6db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/ecto/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ defmodule Ecto.Repo do
contains either atoms, for named Ecto repositories, or
PIDs.
"""
@spec all() :: [atom() | pid()]
defdelegate all(), to: Ecto.Repo.Registry
@spec all_running() :: [atom() | pid()]
defdelegate all_running(), to: Ecto.Repo.Registry

@doc false
defmacro __using__(opts) do
Expand Down
2 changes: 1 addition & 1 deletion lib/ecto/repo/registry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Ecto.Repo.Registry do
GenServer.call(__MODULE__, {:associate, pid, name, value})
end

def all() do
def all_running() do
for [pid, name] <- :ets.match(__MODULE__, {:"$1", :_, :"$2", :_}) do
name || pid
end
Expand Down
8 changes: 4 additions & 4 deletions test/ecto/repo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,11 +1506,11 @@ defmodule Ecto.RepoTest do
end
end

describe "all" do
test "lists all repositories" do
assert Ecto.Repo.all() == [Ecto.TestRepo]
describe "all_running" do
test "lists all running repositories" do
assert Ecto.Repo.all_running() == [Ecto.TestRepo]
pid = start_supervised! {Ecto.TestRepo, name: nil}
assert Enum.sort(Ecto.Repo.all()) == [Ecto.TestRepo, pid]
assert Enum.sort(Ecto.Repo.all_running()) == [Ecto.TestRepo, pid]
end
end
end

0 comments on commit 0d5a6db

Please sign in to comment.