test: QueryBuilder recent_position_packets/callsign_history/weather_packets
This commit is contained in:
parent
ded72eabfb
commit
d9f07e313a
1 changed files with 58 additions and 0 deletions
|
|
@ -235,4 +235,62 @@ defmodule Aprsme.Packets.QueryBuilderTest do
|
|||
assert is_list(query |> limit(10) |> Aprsme.Repo.all())
|
||||
end
|
||||
end
|
||||
|
||||
describe "recent_position_packets/1" do
|
||||
test "returns a list without raising" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.recent_position_packets()))
|
||||
end
|
||||
|
||||
test "accepts keyword list opts" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.recent_position_packets(limit: 10, hours_back: 1)))
|
||||
end
|
||||
|
||||
test "accepts map opts with string keys" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.recent_position_packets(%{"limit" => 10, "hours_back" => 1})))
|
||||
end
|
||||
end
|
||||
|
||||
describe "callsign_history/2" do
|
||||
test "returns a list without raising" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.callsign_history("TEST-1")))
|
||||
end
|
||||
|
||||
test "supports hours_back in map form" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.callsign_history("TEST-1", %{hours_back: 2})))
|
||||
end
|
||||
end
|
||||
|
||||
describe "weather_packets/1" do
|
||||
test "returns a list without raising" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.weather_packets()))
|
||||
end
|
||||
|
||||
test "supports callsign filter" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.weather_packets(%{callsign: "WXHELPER"})))
|
||||
end
|
||||
|
||||
test "supports string callsign filter" do
|
||||
assert is_list(Aprsme.Repo.all(QueryBuilder.weather_packets(%{"callsign" => "WXHELPER"})))
|
||||
end
|
||||
end
|
||||
|
||||
describe "maybe_filter_region/2" do
|
||||
test "keyword opts without region is a no-op" do
|
||||
query = QueryBuilder.maybe_filter_region(Packet, limit: 10)
|
||||
assert is_list(query |> limit(5) |> Aprsme.Repo.all())
|
||||
end
|
||||
|
||||
test "map opts with nil region is a no-op" do
|
||||
query = QueryBuilder.maybe_filter_region(Packet, %{region: nil})
|
||||
assert is_list(query |> limit(5) |> Aprsme.Repo.all())
|
||||
end
|
||||
end
|
||||
|
||||
describe "select_map_fields/1" do
|
||||
test "returns only the subset of fields used for map rendering" do
|
||||
query = QueryBuilder.select_map_fields(Packet)
|
||||
results = query |> limit(3) |> Aprsme.Repo.all()
|
||||
assert is_list(results)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue