From 9dcb673139f56ea65a17cd5864987e87c4084f19 Mon Sep 17 00:00:00 2001 From: Matt Beanland Date: Fri, 22 May 2026 22:12:50 +0930 Subject: [PATCH] test case shows bug fixed --- .../extension/characteristic_test.exs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/provider/extension/characteristic_test.exs b/test/provider/extension/characteristic_test.exs index 06dbad2..864b331 100644 --- a/test/provider/extension/characteristic_test.exs +++ b/test/provider/extension/characteristic_test.exs @@ -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() @@ -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