From dc1b9d8bcbc0b3f058e184541d09add8ee6bceab Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 24 Apr 2026 08:44:04 -0500 Subject: [PATCH] test: Packets error paths --- test/aprsme/packets_test.exs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/aprsme/packets_test.exs b/test/aprsme/packets_test.exs index ea8c643..93a4b0f 100644 --- a/test/aprsme/packets_test.exs +++ b/test/aprsme/packets_test.exs @@ -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"}