Skip to content

Commit

Permalink
feat: Improve custom field tests to contain usage test
Browse files Browse the repository at this point in the history
  • Loading branch information
amhn authored and smutel committed May 23, 2023
1 parent d3b2316 commit 2eb5668
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 0 deletions.
11 changes: 11 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_boolean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ func testAccCheckNetboxExtrasCustomFieldBooleanConfig(nameSuffix string, resourc
default = true
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = false
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
11 changes: 11 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ func testAccCheckNetboxExtrasCustomFieldDateConfig(nameSuffix string, resourceFu
default = jsonencode("2022-01-01")
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = "2023-01-25"
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
11 changes: 11 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_integer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ func testAccCheckNetboxExtrasCustomFieldIntegerConfig(nameSuffix string, resourc
validation_maximum = 500
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = 25
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
19 changes: 19 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ func testAccCheckNetboxExtrasCustomFieldJSONConfig(nameSuffix string, resourceFu
})
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = jsonencode(
{
mystring = "string"
mynumber = 6
mydict = {
mybool = false
}
}
)
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
11 changes: 11 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_longtext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ func testAccCheckNetboxExtrasCustomFieldLongtextConfig(nameSuffix string, resour
validation_regex = "^.*$"
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = "My text"
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ func testAccCheckNetboxExtrasCustomFieldMultiObjectConfig(nameSuffix string, res
])
{{ end }}
}
{{ if eq .extraresources "true" }}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = jsonencode(
[
netbox_dcim_platform.test.id,
]
)
}
}
{{ end }}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ func testAccCheckNetboxExtrasCustomFieldMultiSelectConfig(nameSuffix string, res
default = jsonencode(["test"])
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = jsonencode(
[
"test2",
]
)
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
13 changes: 13 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ func testAccCheckNetboxExtrasCustomFieldObjectConfig(nameSuffix string, resource
)
{{ end }}
}
{{ if eq .extraresources "true" }}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = netbox_dcim_platform.test.id
}
}
{{ end }}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
11 changes: 11 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ func testAccCheckNetboxExtrasCustomFieldSelectConfig(nameSuffix string, resource
default = jsonencode("test")
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = "test2"
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
11 changes: 11 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ func testAccCheckNetboxExtrasCustomFieldTextConfig(nameSuffix string, resourceFu
validation_regex = "^.*$"
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = "My text"
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down
11 changes: 11 additions & 0 deletions netbox/extras/resource_netbox_extras_custom_field_url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ func testAccCheckNetboxExtrasCustomFieldURLConfig(nameSuffix string, resourceFul
default = jsonencode("https://netbox.dev/")
{{ end }}
}
resource "netbox_dcim_site" "test_assign" {
name = "test-a-{{ .namesuffix }}"
slug = "test-a-{{ .namesuffix }}"
custom_field {
name = netbox_extras_custom_field.test.name
type = netbox_extras_custom_field.test.type
value = "http://my.example.url.invalid/path"
}
}
`
data := map[string]string{
"namesuffix": nameSuffix,
Expand Down

0 comments on commit 2eb5668

Please sign in to comment.