test: Packets error paths

This commit is contained in:
Graham McIntire 2026-04-24 08:44:04 -05:00
parent 6afeb7a815
commit dc1b9d8bcb
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -292,6 +292,22 @@ defmodule Aprsme.PacketsTest do
end
end
describe "store_packet/1 error paths" do
test "storage exception path stores a bad packet" do
# Send data that causes changeset insertion to fail at the DB level.
# raw_packet too long exceeds any reasonable schema constraint, or we
# can force a validation error via missing required fields.
packet_data = %{
sender: "",
raw_packet: "BAD"
}
result = Packets.store_packet(packet_data)
# Either ValidationError or :storage_exception — both paths log and store BadPacket.
assert result == {:error, :validation_error} or result == {:error, :storage_exception}
end
end
describe "store_bad_packet/2" do
test "stores bad packet from string" do
error = %{message: "Parse error", type: "ParseError"}