fix: rewrite transform tests to use correct Infrahub pytest format (#20)

Rewrite all three test.yml files to use the Infrahub SDK pytest format
(version: "1.0" / infrahub_tests) instead of the previous invalid
apiVersion/kind schema. Each test file now declares a smoke_check test
(jinja2-transform-smoke) and a unit render test (jinja2-transform-unit-render)
pointing to the local input/output JSON fixtures.

Update output.json files with the actual render output from the fixed templates:
- vlan_yang: trunk_groups is null (not []) for VLANs with no trunk groups set;
  key order reflects Python dict / tojson serialization order.
- interface_yang: corrected MLAG peer-link SVI IP (10.0.199.254/31), added
  iBGP SVI IP (10.0.3.0/31), removed stale Loopback1 IP address.
- vxlan_yang: source_address now includes /32 prefix as stored in Infrahub
  IPHost fields; key order matches tojson output.

Update input.json files to be consistent with the expected output:
- vlan_yang/input.json: trunk_groups.value set to null for VLAN 40.
- interface_yang/input.json: Loopback1 ip_addresses cleared; Vlan4090 IP
  updated to 10.0.199.254/31; Vlan4091 IP added as 10.0.3.0/31.
- vxlan_yang/input.json: source_address updated to 10.0.255.11/32.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Damien
2026-02-28 18:30:10 +01:00
parent a415de85bd
commit a492aa3c39
9 changed files with 77 additions and 170 deletions

View File

@@ -29,7 +29,7 @@
"value": "standard"
},
"trunk_groups": {
"value": []
"value": null
},
"stp_enabled": {
"value": true

View File

@@ -1,31 +1,31 @@
[
{
"vlan_id": 40,
"name": "test-l2-vxlan",
"status": "ACTIVE",
"vlan_type": "standard",
"trunk_groups": [],
"stp_enabled": true,
"trunk_groups": null,
"vlan_id": 40,
"vlan_type": "standard",
"vni": 110040,
"vni_type": "l2vni"
},
{
"vlan_id": 4090,
"name": "mlag-peer",
"status": "ACTIVE",
"vlan_type": "mlag_peer",
"trunk_groups": ["mlag-peer"],
"stp_enabled": false,
"trunk_groups": ["mlag-peer"],
"vlan_id": 4090,
"vlan_type": "mlag_peer",
"vni": null,
"vni_type": null
},
{
"vlan_id": 4091,
"name": "mlag-ibgp",
"status": "ACTIVE",
"vlan_type": "mlag_ibgp",
"trunk_groups": ["mlag-peer"],
"stp_enabled": false,
"trunk_groups": ["mlag-peer"],
"vlan_id": 4091,
"vlan_type": "mlag_ibgp",
"vni": null,
"vni_type": null
}

View File

@@ -1,13 +1,15 @@
---
# Integration test for vlan_yang_transform
# Usage: infrahubctl test transforms/tests/vlan_yang/test.yml
apiVersion: infrahub.app/v1
kind: IntegrationTest
spec:
kind: jinja2-transform-integration
name: vlan_yang_transform_leaf1
transform: vlan_yang_transform
params:
device_name: leaf1
input: input.json
output: output.json
version: "1.0"
infrahub_tests:
- resource: Jinja2Transform
resource_name: vlan_yang_transform
tests:
- name: smoke_check
spec:
kind: jinja2-transform-smoke
- name: render_leaf1
spec:
kind: jinja2-transform-unit-render
directory: transforms/tests/vlan_yang
input: input.json
output: output.json