-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathresource_cloudstack_network_validation_test.go
More file actions
50 lines (44 loc) · 1.35 KB
/
resource_cloudstack_network_validation_test.go
File metadata and controls
50 lines (44 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cloudstack
import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func TestResourceCloudStackNetworkSchema(t *testing.T) {
networkResource := resourceCloudStackNetwork()
// Test that required fields exist
t.Run("Schema should have type field", func(t *testing.T) {
if typeField, ok := networkResource.Schema["type"]; !ok {
t.Error("Schema should have 'type' field")
} else {
if typeField.Type != schema.TypeString {
t.Errorf("Type field should be TypeString, got: %v", typeField.Type)
}
if typeField.Required {
t.Error("Type field should not be required")
}
if typeField.Optional != true {
t.Error("Type field should be optional")
}
if typeField.Default != "L3" {
t.Errorf("Type field default should be 'L3', got: %v", typeField.Default)
}
}
})
t.Run("Schema should have cidr field as optional", func(t *testing.T) {
if cidrField, ok := networkResource.Schema["cidr"]; !ok {
t.Error("Schema should have 'cidr' field")
} else {
if cidrField.Required {
t.Error("CIDR field should not be required")
}
if cidrField.Optional != true {
t.Error("CIDR field should be optional")
}
}
})
t.Run("Schema should have CustomizeDiff", func(t *testing.T) {
if networkResource.CustomizeDiff == nil {
t.Error("Resource should have CustomizeDiff function")
}
})
}