Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions test/provider/extension/characteristic_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Diffo.Provider.Extension.CharacteristicTest do
use ExUnit.Case, async: true
@moduletag :domain_extended
alias Diffo.Test.Parties
alias Diffo.Test.Servo

setup do
AshNeo4j.Sandbox.checkout()
Expand All @@ -23,4 +24,34 @@ defmodule Diffo.Provider.Extension.CharacteristicTest do
assert Diffo.Unwrap.unwrap(shelves) == []
end
end

# Regression coverage for issue #62 — invalid keys or invalid value types
# supplied to a typed characteristic update must surface an error rather than
# being silently dropped or persisted as-is.
describe "typed characteristic update validation (#62)" do
test "valid update succeeds" do
{:ok, shelf} = Parties.build_shelf_with_installer()

updates = [shelf: [family: :ISAM, model: "EBLT48", technology: :adsl2Plus]]

assert {:ok, _} = Servo.define_shelf(shelf, %{characteristic_value_updates: updates})
end

test "unknown field is rejected" do
{:ok, shelf} = Parties.build_shelf_with_installer()

updates = [shelf: [family: :ISAM, cvc_id: "CVC-POI-SYD-001"]]

assert {:error, _} = Servo.define_shelf(shelf, %{characteristic_value_updates: updates})
end

test "invalid value type is rejected" do
{:ok, shelf} = Parties.build_shelf_with_installer()

# :family is :atom — a bare map cannot be cast to an atom
updates = [shelf: [family: %{not: :an_atom}]]

assert {:error, _} = Servo.define_shelf(shelf, %{characteristic_value_updates: updates})
end
end
end
Loading