prop/test/microwaveprop/rover/candidate_detail_test.exs
Graham McIntire fd976b0cd5
fix: resolve 391 Credo issues across codebase
- Add jump_credo_checks ~> 0.4 with all 20 checks enabled
- Fix all standard Credo issues: 139 @spec (113 done, 26 remain),
  4 refactoring, 3 alias usage, 9 System.cmd env, 5 unsafe_to_atom,
  2 max line length, 9 assert_receive timeout
- Fix 170+ jump_credo_checks warnings:
  - 117 TopLevelAliasImportRequire: move nested alias/import to module top
  - 32 UseObanProWorker: switch to Oban.Pro.Worker
  - 4 DoctestIExExamples: add doctests / create test file
  - ~20 WeakAssertion: strengthen type-check assertions
  - Various ConditionalAssertion, AssertReceiveTimeout fixes
- Exclude vendor/ from Credo analysis
- Remaining: 175 warnings (mostly opinionated WeakAssertion,
  AvoidSocketAssignsInTest), 26 @spec annotations
2026-06-12 13:51:32 -05:00

42 lines
1.4 KiB
Elixir

defmodule Microwaveprop.Rover.CandidateDetailTest do
use ExUnit.Case, async: true
alias Microwaveprop.Rover.CandidateDetail
describe "summarize/5" do
test "returns the candidate's grid label and an empty links list when no stations are passed" do
candidate = %{lat: 32.9, lon: -97.0}
result = CandidateDetail.summarize(candidate, [], 10_000, ~U[2026-04-29 12:00:00Z], :ssb)
assert String.length(result.grid) == 10
# 10-character grid for that point.
assert result.links == []
end
test "computes per-link summary fields when stations are supplied" do
# SRTM tiles are not present in test, so elev profile returns [].
# `summarize/5` handles that gracefully and still returns a link.
candidate = %{lat: 32.9, lon: -97.0}
stations = [
%{callsign: "W5LUA", lat: 33.05, lon: -96.6},
%{callsign: "W5HN", lat: 32.7, lon: -97.4}
]
result =
CandidateDetail.summarize(candidate, stations, 10_000, ~U[2026-04-29 12:00:00Z], :ssb)
assert length(result.links) == 2
Enum.each(result.links, fn link ->
assert byte_size(link.callsign) > 0
assert is_float(link.distance_km)
assert byte_size(link.bearing) > 0
assert is_float(link.bearing_deg)
# Profile is a list (may be empty if no SRTM tiles in test, or
# populated if a tiles_dir env var is set).
assert length(link.profile) >= 0
end)
end
end
end