aprs.me/test/support/mock_helpers.ex
Graham McIntire 41c148650d
refactor: Remove CachedQueries and rename optimized functions
- Remove all CachedQueries usage throughout the codebase
- Replace with direct Packets module calls
- Delete CachedQueries module entirely
- Rename get_recent_packets_optimized to get_recent_packets
- Add has_weather_packets? function to Packets module
- Fix duplicate function definitions
- Update all test references to use new function names

This simplifies the codebase by removing the caching layer and
eliminates the database ownership errors in tests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 13:17:56 -05:00

32 lines
843 B
Elixir

defmodule Aprsme.MockHelpers do
@moduledoc """
Helper functions for setting up mocks in tests.
"""
def stub_packets_mock do
# Stub the packets module to prevent external calls
Mox.stub(Aprsme.PacketsMock, :get_packets_for_callsign, fn _callsign ->
{:ok, []}
end)
Mox.stub(Aprsme.PacketsMock, :get_packets_for_callsign_with_limit, fn _callsign, _limit ->
{:ok, []}
end)
Mox.stub(Aprsme.PacketsMock, :get_packets_for_callsign_with_date_range, fn _callsign, _start_date, _end_date ->
{:ok, []}
end)
Mox.stub(Aprsme.PacketsMock, :get_recent_packets, fn _opts ->
[]
end)
Mox.stub(Aprsme.PacketsMock, :get_nearby_stations, fn _lat, _lon, _exclude, _opts ->
[]
end)
end
def stub_badpackets_mock do
Mox.stub_with(BadPacketsMock, BadPacketsStub)
end
end