test(01-03): add failing tests for custom field spec and provisioning
This commit is contained in:
parent
f15c0c7ea7
commit
07130d2ceb
1 changed files with 54 additions and 0 deletions
54
internal/netbox/provision_test.go
Normal file
54
internal/netbox/provision_test.go
Normal file
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue