test: DeviceIdentification lookup_device_from_db fallback path
This commit is contained in:
parent
4f23c4005c
commit
093713f042
1 changed files with 21 additions and 0 deletions
|
|
@ -203,6 +203,27 @@ defmodule Aprsme.DeviceIdentificationTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "lookup_device_from_db fallback when cache is unavailable" do
|
||||||
|
test "lookup_device_by_identifier falls back to direct DB when DeviceCache is unavailable" do
|
||||||
|
Repo.delete_all(Devices)
|
||||||
|
|
||||||
|
Repo.insert!(%Devices{
|
||||||
|
identifier: "DBEXACT",
|
||||||
|
vendor: "Test",
|
||||||
|
model: "Exact"
|
||||||
|
})
|
||||||
|
|
||||||
|
# Clear the cache so the code path exercises the DB lookup.
|
||||||
|
Aprsme.Cache.put(:device_cache, :all_devices, nil)
|
||||||
|
|
||||||
|
# Cache miss → DeviceCache returns nil and also triggers async refresh.
|
||||||
|
# Direct lookup_device_by_identifier goes via DeviceCache here.
|
||||||
|
result = DeviceIdentification.lookup_device_by_identifier("DBEXACT")
|
||||||
|
# Either cache miss → nil, or cache refresh filled and matched.
|
||||||
|
assert is_nil(result) or (is_struct(result, Devices) and result.identifier == "DBEXACT")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "upsert_devices/1 with all three groups" do
|
describe "upsert_devices/1 with all three groups" do
|
||||||
test "processes devices from mice and micelegacy groups" do
|
test "processes devices from mice and micelegacy groups" do
|
||||||
Repo.delete_all(Devices)
|
Repo.delete_all(Devices)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue