Add coverage tests for AprsSymbol render helpers and DbOptimizer atom/identifier paths

This commit is contained in:
Graham McIntire 2026-05-08 12:15:46 -05:00
parent 4bf1a6b3b3
commit 5066cf7c3b
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
2 changed files with 60 additions and 0 deletions

View file

@ -170,4 +170,24 @@ defmodule Aprsme.DbOptimizerTest do
assert :error = DbOptimizer.vacuum_table("packets", analyze: false)
end
end
describe "validate_identifier! and quote_identifier via atoms" do
test "analyze_table accepts an atom name (converts to string)" do
# Exercises validate_identifier!(atom) → string version and
# quote_identifier(atom) → string version (both defp helpers).
result = DbOptimizer.analyze_table(:packets)
assert result == :ok or result == :error
end
test "analyze_table returns :error for invalid identifier characters" do
# validate_identifier! raises ArgumentError, but the surrounding rescue
# in analyze_table converts it to :error.
assert :error = DbOptimizer.analyze_table("not-a-valid;identifier")
end
test "vacuum_table accepts atom names" do
result = DbOptimizer.vacuum_table(:packets, full: false, analyze: false)
assert result == :ok or result == :error
end
end
end

View file

@ -149,6 +149,46 @@ defmodule AprsmeWeb.AprsSymbolTest do
end
end
describe "render_marker_html/4 default arg coverage" do
test "renders without callsign or size args (uses defaults)" do
html = AprsSymbol.render_marker_html("/", ">")
assert is_binary(html)
assert html =~ "background-image"
end
test "renders without callsign with explicit size" do
html = AprsSymbol.render_marker_html("/", ">", nil, 32)
assert is_binary(html)
end
test "renders an overlay marker without callsign" do
html = AprsSymbol.render_marker_html("A", ">", nil)
assert is_binary(html)
end
end
describe "render_style/3 default arg coverage" do
test "renders an inline style string with default size" do
style = AprsSymbol.render_style("/", ">")
assert is_binary(style)
assert style =~ "background-image"
end
test "renders an inline style string with explicit size" do
style = AprsSymbol.render_style("/", ">", 64)
assert style =~ "64px"
end
end
describe "get_symbol_code_ord fallback via get_sprite_info" do
test "non-binary symbol_code yields default ord (?)" do
# nil/integer symbol_code lands on the catch-all in get_symbol_code_ord/1
info = AprsSymbol.get_sprite_info("/", nil)
assert is_map(info)
assert is_binary(info.sprite_file)
end
end
describe "normalize helpers" do
test "normalize_symbol_table maps overlay characters to ']' table" do
# Single alphanumeric → overlay table