From 6e1a1bd7dbc4d828849485921bf4492e691a4505 Mon Sep 17 00:00:00 2001 From: Jon Chery Date: Wed, 29 Jul 2026 20:17:55 +0000 Subject: [PATCH] docs(P01): complete adapter-dedup-diagnostic phase (v1.13.4) ---ci--- project: acdl phase: 1 milestone: v1.14 status: complete requirements: covered: [REQ-135] partial: [] ---/ci--- --- tests/test_adapter.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/test_adapter.py b/tests/test_adapter.py index a1ee5f4..097393d 100644 --- a/tests/test_adapter.py +++ b/tests/test_adapter.py @@ -330,4 +330,35 @@ class TestChildIdHelper: # ecs-service expands to service-task-definition + service-service assert _child_id(["service-task-definition", "service-service"]) == "service" # alb expands to alb-loadbalancer + alb-targetgroup + alb-listener - assert _child_id(["alb-loadbalancer", "alb-targetgroup", "alb-listener"]) == "alb" \ No newline at end of file + assert _child_id(["alb-loadbalancer", "alb-targetgroup", "alb-listener"]) == "alb" + + +class TestAdapterDedupRejectsUnregisteredModule: + """P1-1 (v1.14, REQ-135): a resource whose module is not in the + registry must raise ValueError, not be silently dropped from the + dedup merge. A typo'd module field (e.g. 'iam-role' vs 'iam_roles') + must surface as a diagnostic, not vanish.""" + + def test_unregistered_module_raises_valueerror(self, tmp_path): + stack = { + "resources": [ + {"id": "bad", "type": "aws:bogus:thing", "module": "nonexistent@1.0.0", "inputs": {}} + ], + "outputs": {}, + "data_sources": [], + } + with pytest.raises(ValueError, match="no terraform_dir for module 'nonexistent'"): + adapt(stack, str(tmp_path)) + + def test_registered_module_still_works(self, tmp_path): + """A registered module (s3) must still emit valid terraform — the + ValueError guard must not break the happy path.""" + stack = { + "resources": [ + {"id": "s3", "type": "aws:s3:bucket", "module": "s3@1.0.0", "inputs": {"bucket_name": "test"}} + ], + "outputs": {}, + "data_sources": [], + } + adapt(stack, str(tmp_path)) + assert (tmp_path / "main.tf").exists() \ No newline at end of file