From 07130d2cebe9efa1f67222b2b3fe91e7b82b21a8 Mon Sep 17 00:00:00 2001 From: Mikkel Georgsen Date: Fri, 10 Apr 2026 05:20:37 +0000 Subject: [PATCH] test(01-03): add failing tests for custom field spec and provisioning --- internal/netbox/provision_test.go | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 internal/netbox/provision_test.go diff --git a/internal/netbox/provision_test.go b/internal/netbox/provision_test.go new file mode 100644 index 0000000..dd4bae0 --- /dev/null +++ b/internal/netbox/provision_test.go @@ -0,0 +1,54 @@ +package netbox + +import ( + "testing" +) + +func TestCustomFieldSpec(t *testing.T) { + spec := customFieldSpec("hw_id") + if spec == nil { + t.Fatal("hw_id spec not found") + } + if spec.Type != "text" { + t.Errorf("hw_id type: want text, got %s", spec.Type) + } + for _, ot := range spec.ObjectTypes { + if ot == "dcim.device" { + return + } + } + t.Error("hw_id ObjectTypes must include dcim.device") +} + +func TestCustomFieldSpecCatalogStatus(t *testing.T) { + spec := customFieldSpec("catalog_status") + if spec == nil { + t.Fatal("catalog_status spec not found") + } + if spec.Type != "text" { + t.Errorf("catalog_status type: want text (not selection), got %s", spec.Type) + } +} + +func TestCustomFieldSpecPhotoURLs(t *testing.T) { + spec := customFieldSpec("photo_urls") + if spec == nil { + t.Fatal("photo_urls spec not found") + } + if spec.Description == "" { + t.Error("photo_urls must have a description") + } +} + +func TestAllEightFieldsDefined(t *testing.T) { + expected := []string{"hw_id", "catalog_status", "product_url", "firmware_version", + "test_date", "test_data", "ai_notes", "photo_urls"} + for _, name := range expected { + if customFieldSpec(name) == nil { + t.Errorf("missing custom field spec: %s", name) + } + } + if len(hwlabCustomFields) != 8 { + t.Errorf("want 8 custom fields, got %d", len(hwlabCustomFields)) + } +}