- Rover.Compute: road/prominence/clearance/clutter/canopy tests (90%) - Rover.Prominence: full unit test suite with mock elev_lookup (100%) - Rover.Elevation: dedup + multi-tile tests (44%) - Rover.LinkMargin: edge cases, negative scores, all modes (57%) - Rover.Location: changeset validation + statuses/0 (100%) - RoverPlanning.Path: changeset validation + statuses/0 (67%) - Pskr.FeatureBin: changeset validation (100%) - Pskr.Mqtt: QoS reject, unknown type, varint overflow, ping/disconnect (97%) - Valkey: not-configured error paths, empty guards (55%) - ScoresController: bad params, time format, missing band tests (81%) - SkewtLive: info/no-profiles state, loading states (29%)
87 lines
2.5 KiB
Elixir
87 lines
2.5 KiB
Elixir
defmodule Microwaveprop.RoverPlanning.PathTest do
|
|
use Microwaveprop.DataCase, async: true
|
|
|
|
alias Microwaveprop.RoverPlanning.Path
|
|
|
|
describe "changeset/2" do
|
|
test "valid attrs produce a valid changeset" do
|
|
attrs = %{
|
|
mission_id: Ecto.UUID.generate(),
|
|
rover_location_id: Ecto.UUID.generate(),
|
|
station_id: Ecto.UUID.generate(),
|
|
band_mhz: 10_000,
|
|
status: :pending
|
|
}
|
|
|
|
changeset = Path.changeset(%Path{}, attrs)
|
|
assert changeset.valid?
|
|
end
|
|
|
|
test "missing required fields makes changeset invalid" do
|
|
changeset = Path.changeset(%Path{}, %{})
|
|
refute changeset.valid?
|
|
assert "can't be blank" in errors_on(changeset).mission_id
|
|
assert "can't be blank" in errors_on(changeset).rover_location_id
|
|
assert "can't be blank" in errors_on(changeset).station_id
|
|
assert "can't be blank" in errors_on(changeset).band_mhz
|
|
end
|
|
|
|
test "rejects invalid status" do
|
|
attrs = %{
|
|
mission_id: Ecto.UUID.generate(),
|
|
rover_location_id: Ecto.UUID.generate(),
|
|
station_id: Ecto.UUID.generate(),
|
|
band_mhz: 10_000,
|
|
status: :invalid_status
|
|
}
|
|
|
|
changeset = Path.changeset(%Path{}, attrs)
|
|
refute changeset.valid?
|
|
assert "is invalid" in errors_on(changeset).status
|
|
end
|
|
|
|
test "rejects zero or negative band_mhz" do
|
|
attrs = %{
|
|
mission_id: Ecto.UUID.generate(),
|
|
rover_location_id: Ecto.UUID.generate(),
|
|
station_id: Ecto.UUID.generate(),
|
|
band_mhz: 0,
|
|
status: :pending
|
|
}
|
|
|
|
changeset = Path.changeset(%Path{}, attrs)
|
|
refute changeset.valid?
|
|
assert "must be greater than 0" in errors_on(changeset).band_mhz
|
|
end
|
|
|
|
test "accepts complete and failed statuses" do
|
|
for status <- [:complete, :failed] do
|
|
attrs = %{
|
|
mission_id: Ecto.UUID.generate(),
|
|
rover_location_id: Ecto.UUID.generate(),
|
|
station_id: Ecto.UUID.generate(),
|
|
band_mhz: 10_000,
|
|
status: status
|
|
}
|
|
|
|
changeset = Path.changeset(%Path{}, attrs)
|
|
assert changeset.valid?, "status :#{status} should be valid"
|
|
end
|
|
end
|
|
|
|
test "accepts optional result and error fields" do
|
|
attrs = %{
|
|
mission_id: Ecto.UUID.generate(),
|
|
rover_location_id: Ecto.UUID.generate(),
|
|
station_id: Ecto.UUID.generate(),
|
|
band_mhz: 10_000,
|
|
status: :failed,
|
|
result: nil,
|
|
error: "timeout"
|
|
}
|
|
|
|
changeset = Path.changeset(%Path{}, attrs)
|
|
assert changeset.valid?
|
|
end
|
|
end
|
|
end
|