- Delete dead config keys and test file (typo'd aprsme_is_*, vacuous disable test) - Remove duplicate function clauses and identical function pairs - Rename misleading one_hour_ago variable to one_day_ago - Strip stale Oban comment - Remove TestHelpers time function duplicates - Inline Aprsme.Schema module (only 1 caller) - Deduplicate prod esbuild config - Thin SymbolRenderer delegations, inline TimeUtils wrappers - Remove redundant DeploymentNotifier GenServer polling - Replace random fallback in get_callsign_key with sentinel
56 lines
1.7 KiB
Elixir
56 lines
1.7 KiB
Elixir
defmodule AprsmeWeb.TestHelpersTest do
|
|
use Aprsme.DataCase, async: true
|
|
|
|
alias AprsmeWeb.TestHelpers
|
|
|
|
describe "create_test_packet/1" do
|
|
test "creates a packet with defaults" do
|
|
{:ok, packet} = TestHelpers.create_test_packet()
|
|
assert packet.sender == "TEST-1"
|
|
assert packet.base_callsign == "TEST"
|
|
end
|
|
|
|
test "overrides with attrs" do
|
|
{:ok, packet} = TestHelpers.create_test_packet(%{sender: "CUSTOM-9"})
|
|
assert packet.sender == "CUSTOM-9"
|
|
end
|
|
|
|
test "creates packet with weather attrs" do
|
|
{:ok, packet} =
|
|
TestHelpers.create_test_packet(%{
|
|
sender: "WXHELPER",
|
|
temperature: 72.0,
|
|
humidity: 50.0,
|
|
wind_speed: 5.0
|
|
})
|
|
|
|
assert packet.temperature == 72.0
|
|
assert packet.humidity == 50.0
|
|
assert packet.wind_speed == 5.0
|
|
end
|
|
end
|
|
|
|
describe "bounds helpers" do
|
|
test "texas_bounds returns a map with all four directions" do
|
|
bounds = TestHelpers.texas_bounds()
|
|
assert %{"north" => _, "south" => _, "east" => _, "west" => _} = bounds
|
|
end
|
|
|
|
test "restrictive_bounds returns a map with all four directions" do
|
|
bounds = TestHelpers.restrictive_bounds()
|
|
assert %{"north" => _, "south" => _, "east" => _, "west" => _} = bounds
|
|
end
|
|
end
|
|
|
|
describe "time helpers" do
|
|
test "hours_ago returns a DateTime earlier than now" do
|
|
then_dt = AprsmeWeb.TimeUtils.hours_ago(2)
|
|
assert DateTime.before?(then_dt, DateTime.utc_now())
|
|
end
|
|
|
|
test "days_ago returns a DateTime earlier than now" do
|
|
then_dt = AprsmeWeb.TimeUtils.days_ago(3)
|
|
assert DateTime.before?(then_dt, DateTime.utc_now())
|
|
end
|
|
end
|
|
end
|